mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 12:57:13 +02:00
rxr: removed return ok or fail and replaced with exceptions
This commit is contained in:
@ -51,17 +51,15 @@ class BinaryFile : private virtual slsDetectorDefs, public File, public BinaryFi
|
||||
|
||||
/**
|
||||
* Create file
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int CreateFile() override;
|
||||
void CreateFile() override;
|
||||
|
||||
/**
|
||||
* Create master file
|
||||
* @param mfwenable master file write enable
|
||||
* @param attr master file attributes
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int CreateMasterFile(bool mfwenable, masterAttributes& attr) override;
|
||||
void CreateMasterFile(bool mfwenable, masterAttributes& attr) override;
|
||||
|
||||
/**
|
||||
* Close Current File
|
||||
@ -79,9 +77,8 @@ class BinaryFile : private virtual slsDetectorDefs, public File, public BinaryFi
|
||||
* @param buffersize size of buffer
|
||||
* @param fnum current image number
|
||||
* @param nump number of packets caught
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) override;
|
||||
void WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) override;
|
||||
|
||||
|
||||
|
||||
|
@ -98,23 +98,20 @@ class BinaryFileStatic {
|
||||
* @param fname master file name
|
||||
* @param owenable overwrite enable
|
||||
* @param attr master file attributes
|
||||
* @returns 0 for success and 1 for fail
|
||||
*/
|
||||
static int CreateMasterDataFile(FILE*& fd, std::string fname, bool owenable,
|
||||
static void CreateMasterDataFile(FILE*& fd, std::string fname, bool owenable,
|
||||
masterAttributes& attr)
|
||||
{
|
||||
if(!owenable){
|
||||
if (NULL == (fd = fopen((const char *) fname.c_str(), "wx"))){
|
||||
FILE_LOG(logERROR) << "Could not create binary master file "
|
||||
"(without overwrite enable) " << fname;
|
||||
fd = 0;
|
||||
return 1;
|
||||
throw sls::RuntimeError("Could not create binary master file "
|
||||
"(without overwrite enable) " + fname);
|
||||
}
|
||||
}else if (NULL == (fd = fopen((const char *) fname.c_str(), "w"))){
|
||||
FILE_LOG(logERROR) << "Could not create binary master file "
|
||||
"(with overwrite enable) " << fname;
|
||||
fd = 0;
|
||||
return 1;
|
||||
throw sls::RuntimeError("Could not create binary master file "
|
||||
"(with overwrite enable) " + fname);
|
||||
}
|
||||
time_t t = time(0);
|
||||
char message[MAX_MASTER_FILE_LENGTH];
|
||||
@ -182,16 +179,15 @@ class BinaryFileStatic {
|
||||
attr.roiXmax,
|
||||
ctime(&t));
|
||||
if (strlen(message) > MAX_MASTER_FILE_LENGTH) {
|
||||
FILE_LOG(logERROR) << "Master File Size " << strlen(message) <<
|
||||
" is greater than max str size " << MAX_MASTER_FILE_LENGTH;
|
||||
return 1;
|
||||
throw sls::RuntimeError("Master File Size " + std::to_string(strlen(message)) +
|
||||
" is greater than max str size " + std::to_string(MAX_MASTER_FILE_LENGTH));
|
||||
}
|
||||
|
||||
if (fwrite((void*)message, 1, strlen(message), fd) != strlen(message))
|
||||
return 1;
|
||||
if (fwrite((void*)message, 1, strlen(message), fd) != strlen(message)) {
|
||||
throw sls::RuntimeError("Master binary file incorrect number of bytes written to file");
|
||||
}
|
||||
|
||||
BinaryFileStatic::CloseDataFile(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -203,22 +199,19 @@ class BinaryFileStatic {
|
||||
* @param filebuffersize file buffer size
|
||||
* @returns 0 for success and 1 for fail
|
||||
*/
|
||||
static int CreateDataFile(FILE*& fd, bool owenable, std::string fname, size_t filebuffersize)
|
||||
static void CreateDataFile(FILE*& fd, bool owenable, std::string fname, size_t filebuffersize)
|
||||
{
|
||||
if(!owenable){
|
||||
if (NULL == (fd = fopen((const char *) fname.c_str(), "wx"))){
|
||||
FILE_LOG(logERROR) << "Could not create/overwrite file" << fname;
|
||||
fd = 0;
|
||||
return 1;
|
||||
throw sls::RuntimeError("Could not create/overwrite file " + fname);
|
||||
}
|
||||
}else if (NULL == (fd = fopen((const char *) fname.c_str(), "w"))){
|
||||
FILE_LOG(logERROR) << "Could not create file" << fname;
|
||||
} else if (NULL == (fd = fopen((const char *) fname.c_str(), "w"))){
|
||||
fd = 0;
|
||||
return 1;
|
||||
throw sls::RuntimeError("Could not create file " + fname);
|
||||
}
|
||||
//setting file buffer size to 16mb
|
||||
setvbuf(fd,NULL,_IOFBF,filebuffersize);
|
||||
return 0;
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -121,9 +121,8 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
/**
|
||||
* Set thread priority
|
||||
* @priority priority
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int SetThreadPriority(int priority);
|
||||
void SetThreadPriority(int priority);
|
||||
|
||||
/**
|
||||
* Set File Format
|
||||
@ -155,9 +154,8 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
/**
|
||||
* Create New File
|
||||
* @param attr master file attributes
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int CreateNewFile(masterAttributes& attr);
|
||||
void CreateNewFile(masterAttributes& attr);
|
||||
|
||||
/**
|
||||
* Closes files
|
||||
@ -213,12 +211,6 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
*/
|
||||
void RecordFirstIndex(uint64_t fnum);
|
||||
|
||||
/**
|
||||
* Destroy file writer object
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
void DestroyFileWriter();
|
||||
|
||||
/**
|
||||
* Thread Exeution for DataProcessor Class
|
||||
* Pop bound addresses, process them,
|
||||
|
@ -82,9 +82,8 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
||||
/**
|
||||
* Set thread priority
|
||||
* @priority priority
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int SetThreadPriority(int priority);
|
||||
void SetThreadPriority(int priority);
|
||||
|
||||
/**
|
||||
* Set number of detectors
|
||||
@ -114,9 +113,8 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
||||
|
||||
/**
|
||||
* Restream stop dummy packet
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int RestreamStop();
|
||||
void RestreamStop();
|
||||
|
||||
|
||||
private:
|
||||
|
@ -78,9 +78,8 @@ class Fifo : private virtual slsDetectorDefs {
|
||||
/**
|
||||
* Create Fifos, allocate memory & push addresses into fifo
|
||||
* @param fifoItemSize size of each fifo item
|
||||
* @return OK if successful, else FAIL
|
||||
*/
|
||||
int CreateFifos(uint32_t fifoItemSize);
|
||||
void CreateFifos(uint32_t fifoItemSize);
|
||||
|
||||
/**
|
||||
* Destroy Fifos and deallocate memory
|
||||
|
@ -84,9 +84,8 @@ class File : private virtual slsDetectorDefs {
|
||||
|
||||
/**
|
||||
* Create file
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
virtual int CreateFile() = 0;
|
||||
virtual void CreateFile() = 0;
|
||||
|
||||
/**
|
||||
* Close Current File
|
||||
@ -103,17 +102,15 @@ class File : private virtual slsDetectorDefs {
|
||||
* @param buffer buffer to write from
|
||||
* @param fnum current image number
|
||||
* @param nump number of packets caught
|
||||
* @param OK or FAIL
|
||||
*/
|
||||
virtual int WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) = 0;
|
||||
virtual void WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) = 0;
|
||||
|
||||
/**
|
||||
* Create master file
|
||||
* @param mfwenable master file write enable
|
||||
* @param attr master file attributes
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
virtual int CreateMasterFile(bool mfwenable, masterAttributes& attr) = 0;
|
||||
virtual void CreateMasterFile(bool mfwenable, masterAttributes& attr) = 0;
|
||||
|
||||
// HDf5 specific
|
||||
/**
|
||||
|
@ -67,9 +67,8 @@ class HDF5File : private virtual slsDetectorDefs, public File, public HDF5FileSt
|
||||
/**
|
||||
* Create file
|
||||
* @param fnum current frame index to include in file name
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int CreateFile();
|
||||
void CreateFile();
|
||||
|
||||
/**
|
||||
* Close Current File
|
||||
@ -87,17 +86,15 @@ class HDF5File : private virtual slsDetectorDefs, public File, public HDF5FileSt
|
||||
* @param bsize size of buffer (not used)
|
||||
* @param fnum current image number
|
||||
* @param nump number of packets caught
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int WriteToFile(char* buffer, int bsize, uint64_t fnum, uint32_t nump);
|
||||
void WriteToFile(char* buffer, int bsize, uint64_t fnum, uint32_t nump);
|
||||
|
||||
/**
|
||||
* Create master file
|
||||
* @param mfwenable master file write enable
|
||||
* @param attr master file attributes
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int CreateMasterFile(bool mfwenable, masterAttributes& attr);
|
||||
void CreateMasterFile(bool mfwenable, masterAttributes& attr);
|
||||
|
||||
/**
|
||||
* End of Acquisition
|
||||
@ -112,16 +109,14 @@ class HDF5File : private virtual slsDetectorDefs, public File, public HDF5FileSt
|
||||
/**
|
||||
* Create Virtual File
|
||||
* @param numf number of images caught
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int CreateVirtualFile(uint64_t numf);
|
||||
void CreateVirtualFile(uint64_t numf);
|
||||
|
||||
/**
|
||||
* Link virtual file in master file
|
||||
* Only for Jungfrau at the moment for 1 module and 1 data file
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int LinkVirtualFileinMasterFile();
|
||||
void LinkVirtualFileinMasterFile();
|
||||
|
||||
/**
|
||||
* Get Type
|
||||
|
@ -156,9 +156,8 @@ public:
|
||||
* @param dspace dataspace pointer
|
||||
* @param dset dataset pointer
|
||||
* @param dtype datatype
|
||||
* @returns 0 for success and 1 for fail
|
||||
*/
|
||||
static int WriteDataFile(int ind, char* buf,
|
||||
static void WriteDataFile(int ind, char* buf,
|
||||
uint64_t nDimx, uint32_t nDimy, uint32_t nDimz,
|
||||
DataSpace* dspace, DataSet* dset, DataType dtype)
|
||||
{
|
||||
@ -176,9 +175,8 @@ public:
|
||||
catch(const Exception& error){
|
||||
FILE_LOG(logERROR) << "Could not write to file in object " << ind;
|
||||
error.printErrorStack();
|
||||
return 1;
|
||||
throw RuntimeError("Could not write to file in object " + std::to_string(ind));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -192,7 +190,7 @@ public:
|
||||
* @param rheader sls_receiver_header pointer
|
||||
* @param parameterDataTypes parameter datatypes
|
||||
*/
|
||||
static int WriteParameterDatasets(int ind, DataSpace* dspace_para, uint64_t fnum,
|
||||
static void WriteParameterDatasets(int ind, DataSpace* dspace_para, uint64_t fnum,
|
||||
std::vector <DataSet*> dset_para,sls_receiver_header* rheader,
|
||||
std::vector <DataType> parameterDataTypes)
|
||||
{
|
||||
@ -236,11 +234,9 @@ public:
|
||||
}i=14;
|
||||
}
|
||||
catch(const Exception& error){
|
||||
FILE_LOG(logERROR) << "Could not write parameters (index:" << i << ") to file in object " << ind;
|
||||
error.printErrorStack();
|
||||
return 1;
|
||||
throw RuntimeError("Could not write parameters (index:" + std::to_string(i) + ") to file in object " + std::to_string(ind));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -253,9 +249,8 @@ public:
|
||||
* @param dspace_para parameter dataspace address pointer
|
||||
* @param dset dataset parameter pointer
|
||||
* @param initialNumImages initial number of images
|
||||
* @returns 0 for success and 1 for fail
|
||||
*/
|
||||
static int ExtendDataset(int ind, DataSpace*& dspace, DataSet* dset,
|
||||
static void ExtendDataset(int ind, DataSpace*& dspace, DataSet* dset,
|
||||
DataSpace*& dspace_para, std::vector <DataSet*> dset_para,
|
||||
uint64_t initialNumImages) {
|
||||
try{
|
||||
@ -279,11 +274,9 @@ public:
|
||||
|
||||
}
|
||||
catch(const Exception& error){
|
||||
FILE_LOG(logERROR) << "Could not extend dataset in object " << ind;
|
||||
error.printErrorStack();
|
||||
return 1;
|
||||
throw RuntimeError("Could not extend dataset in object " + std::to_string(ind));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -292,9 +285,8 @@ public:
|
||||
* @param fname master file name
|
||||
* @param owenable overwrite enable
|
||||
* @param attr master file attributes
|
||||
* @returns 0 for success and 1 for fail
|
||||
*/
|
||||
static int CreateMasterDataFile(H5File*& fd, std::string fname, bool owenable,
|
||||
static void CreateMasterDataFile(H5File*& fd, std::string fname, bool owenable,
|
||||
masterAttributes& attr)
|
||||
{
|
||||
try {
|
||||
@ -443,12 +435,10 @@ public:
|
||||
fd->close();
|
||||
|
||||
} catch(const Exception& error) {
|
||||
FILE_LOG(logERROR) << "Could not create master HDF5 handles";
|
||||
error.printErrorStack();
|
||||
if (fd) fd->close();
|
||||
return 1;
|
||||
throw RuntimeError("Could not create master HDF5 handles");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -473,9 +463,8 @@ public:
|
||||
* @param dset_para vector of datasets of parameters
|
||||
* @param parameterNames parameter names
|
||||
* @param parameterDataTypes parameter datatypes
|
||||
* @returns 0 for success and 1 for fail
|
||||
*/
|
||||
static int CreateDataFile(int ind, bool owenable, std::string fname, bool frindexenable,
|
||||
static void CreateDataFile(int ind, bool owenable, std::string fname, bool frindexenable,
|
||||
uint64_t fnum, uint64_t nDimx, uint32_t nDimy, uint32_t nDimz,
|
||||
DataType dtype, H5File*& fd, DataSpace*& dspace, DataSet*& dset,
|
||||
double version, uint64_t maxchunkedimages,
|
||||
@ -547,12 +536,10 @@ public:
|
||||
}
|
||||
}
|
||||
catch(const Exception& error){
|
||||
FILE_LOG(logERROR) << "Could not create HDF5 handles in object " << ind;
|
||||
error.printErrorStack();
|
||||
if (fd) fd->close();
|
||||
return 1;
|
||||
throw RuntimeError("Could not create HDF5 handles in object " + ind);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -579,9 +566,8 @@ public:
|
||||
* @param version version of software for hdf5 writing
|
||||
* @param parameterNames parameter names
|
||||
* @param parameterDataTypes parameter datatypes
|
||||
* @returns 0 for success and 1 for fail
|
||||
*/
|
||||
static int CreateVirtualDataFile(
|
||||
static void CreateVirtualDataFile(
|
||||
std::string virtualFileName,
|
||||
hid_t& fd, std::string masterFileName,
|
||||
std::string fpath, std::string fnameprefix, uint64_t findex, bool frindexenable,
|
||||
@ -593,206 +579,167 @@ public:
|
||||
std::vector <const char*> parameterNames,
|
||||
std::vector <DataType> parameterDataTypes)
|
||||
{
|
||||
//file
|
||||
hid_t dfal = H5Pcreate (H5P_FILE_ACCESS);
|
||||
if (dfal < 0)
|
||||
return CloseFileOnError(fd,
|
||||
std::string("Could not create file access property for virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
if (H5Pset_fclose_degree (dfal, H5F_CLOSE_STRONG) < 0)
|
||||
return CloseFileOnError(fd,
|
||||
std::string("Could not set strong file close degree for virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
fd = H5Fcreate( virtualFileName.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, dfal);
|
||||
if (fd < 0)
|
||||
return CloseFileOnError(fd,
|
||||
std::string("Could not create virtual file ") + virtualFileName + std::string("\n"));
|
||||
try {
|
||||
//file
|
||||
hid_t dfal = H5Pcreate (H5P_FILE_ACCESS);
|
||||
if (dfal < 0)
|
||||
throw RuntimeError("Could not create file access property for virtual file " + virtualFileName);
|
||||
if (H5Pset_fclose_degree (dfal, H5F_CLOSE_STRONG) < 0)
|
||||
throw RuntimeError("Could not set strong file close degree for virtual file " + virtualFileName);
|
||||
fd = H5Fcreate( virtualFileName.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, dfal);
|
||||
if (fd < 0)
|
||||
throw RuntimeError("Could not create virtual file " + virtualFileName);
|
||||
|
||||
//attributes - version
|
||||
hid_t dataspace_attr = H5Screate (H5S_SCALAR);
|
||||
if (dataspace_attr < 0)
|
||||
return CloseFileOnError(fd,
|
||||
std::string("Could not create dataspace for attribute in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
hid_t attrid = H5Acreate2 (fd, "version", H5T_NATIVE_DOUBLE, dataspace_attr, H5P_DEFAULT, H5P_DEFAULT);
|
||||
if (attrid < 0)
|
||||
return CloseFileOnError(fd,
|
||||
std::string("Could not create attribute in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
double attr_data = version;
|
||||
if (H5Awrite (attrid, H5T_NATIVE_DOUBLE, &attr_data) < 0)
|
||||
return CloseFileOnError(fd,
|
||||
std::string("Could not write attribute in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
if (H5Aclose (attrid) < 0)
|
||||
return CloseFileOnError(fd,
|
||||
std::string("Could not close attribute in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
//attributes - version
|
||||
hid_t dataspace_attr = H5Screate (H5S_SCALAR);
|
||||
if (dataspace_attr < 0)
|
||||
throw RuntimeError("Could not create dataspace for attribute in virtual file " + virtualFileName);
|
||||
hid_t attrid = H5Acreate2 (fd, "version", H5T_NATIVE_DOUBLE, dataspace_attr, H5P_DEFAULT, H5P_DEFAULT);
|
||||
if (attrid < 0)
|
||||
throw RuntimeError("Could not create attribute in virtual file " + virtualFileName);
|
||||
double attr_data = version;
|
||||
if (H5Awrite (attrid, H5T_NATIVE_DOUBLE, &attr_data) < 0)
|
||||
throw RuntimeError("Could not write attribute in virtual file " + virtualFileName);
|
||||
if (H5Aclose (attrid) < 0)
|
||||
throw RuntimeError("Could not close attribute in virtual file " + virtualFileName);
|
||||
|
||||
|
||||
//virtual dataspace
|
||||
hsize_t vdsdims[3] = {numf, numDety * nDimy, numDetz * nDimz};
|
||||
hid_t vdsDataspace = H5Screate_simple(3, vdsdims ,NULL);
|
||||
if (vdsDataspace < 0)
|
||||
return CloseFileOnError(fd,
|
||||
std::string("Could not create virtual dataspace in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
hsize_t vdsdims_para[2] = {numf, (unsigned int) numDety * numDetz};
|
||||
hid_t vdsDataspace_para = H5Screate_simple(2, vdsdims_para, NULL);
|
||||
if (vdsDataspace_para < 0)
|
||||
return CloseFileOnError(fd,
|
||||
std::string("Could not create virtual dataspace (parameters) in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
//virtual dataspace
|
||||
hsize_t vdsdims[3] = {numf, numDety * nDimy, numDetz * nDimz};
|
||||
hid_t vdsDataspace = H5Screate_simple(3, vdsdims ,NULL);
|
||||
if (vdsDataspace < 0)
|
||||
throw RuntimeError("Could not create virtual dataspace in virtual file " + virtualFileName);
|
||||
hsize_t vdsdims_para[2] = {numf, (unsigned int) numDety * numDetz};
|
||||
hid_t vdsDataspace_para = H5Screate_simple(2, vdsdims_para, NULL);
|
||||
if (vdsDataspace_para < 0)
|
||||
throw RuntimeError("Could not create virtual dataspace (parameters) in virtual file " + virtualFileName);
|
||||
|
||||
|
||||
//fill values
|
||||
hid_t dcpl = H5Pcreate (H5P_DATASET_CREATE);
|
||||
if (dcpl < 0)
|
||||
return CloseFileOnError(fd,
|
||||
std::string("Could not create file creation properties in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
int fill_value = -1;
|
||||
if (H5Pset_fill_value (dcpl, GetDataTypeinC(dataType), &fill_value) < 0)
|
||||
return CloseFileOnError(fd,
|
||||
std::string("Could not create fill value in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
hid_t dcpl_para[parameterNames.size()];
|
||||
for (unsigned int i = 0; i < parameterNames.size(); ++i) {
|
||||
dcpl_para[i] = H5Pcreate (H5P_DATASET_CREATE);
|
||||
if (dcpl_para[i] < 0)
|
||||
return CloseFileOnError(fd,
|
||||
std::string("Could not create file creation properties (parameters) in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
if (H5Pset_fill_value (dcpl_para[i], GetDataTypeinC(parameterDataTypes[i]), &fill_value) < 0)
|
||||
return CloseFileOnError(fd,
|
||||
std::string("Could not create fill value (parameters) in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
}
|
||||
|
||||
//hyperslab
|
||||
int numMajorHyperslab = numf/maxFramesPerFile;
|
||||
if (numf%maxFramesPerFile) numMajorHyperslab++;
|
||||
bool error = false;
|
||||
uint64_t framesSaved = 0;
|
||||
for (int j = 0; j < numMajorHyperslab; j++) {
|
||||
|
||||
uint64_t nDimx = ((numf - framesSaved) > maxFramesPerFile)
|
||||
? maxFramesPerFile : (numf-framesSaved);
|
||||
hsize_t offset[3] = {framesSaved, 0, 0};
|
||||
hsize_t count[3] = {nDimx, nDimy, nDimz};
|
||||
hsize_t offset_para[2] = {framesSaved, 0};
|
||||
hsize_t count_para[2] = {nDimx, 1};
|
||||
|
||||
for (int i = 0; i < numDety * numDetz; ++i) {
|
||||
|
||||
//setect hyperslabs
|
||||
if (H5Sselect_hyperslab (vdsDataspace, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) {
|
||||
FILE_LOG(logERROR) << "Could not select hyperslab";
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
if (H5Sselect_hyperslab (vdsDataspace_para, H5S_SELECT_SET,
|
||||
offset_para, NULL, count_para, NULL) < 0) {
|
||||
FILE_LOG(logERROR) << "Could not select hyperslab for parameters";
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
|
||||
//source file name
|
||||
std::string srcFileName = HDF5FileStatic::CreateFileName(fpath, fnameprefix, findex,
|
||||
j, dindex, numunits, i);
|
||||
|
||||
FILE_LOG(logERROR) << srcFileName;
|
||||
// find relative path
|
||||
std::string relative_srcFileName = srcFileName;
|
||||
{
|
||||
size_t i = srcFileName.rfind('/', srcFileName.length());
|
||||
if (i != std::string::npos)
|
||||
relative_srcFileName = (srcFileName.substr(i+1, srcFileName.length() - i));
|
||||
}
|
||||
|
||||
//source dataset name
|
||||
std::ostringstream osfn;
|
||||
osfn << "/data";
|
||||
if (frindexenable) osfn << "_f" << std::setfill('0') << std::setw(12) << j;
|
||||
std::string srcDatasetName = osfn.str();
|
||||
|
||||
//source dataspace
|
||||
hsize_t srcdims[3] = {nDimx, nDimy, nDimz};
|
||||
hsize_t srcdimsmax[3] = {H5S_UNLIMITED, nDimy, nDimz};
|
||||
hid_t srcDataspace = H5Screate_simple(3, srcdims, srcdimsmax);
|
||||
if (srcDataspace < 0)
|
||||
return CloseFileOnError(fd,
|
||||
std::string("Could not create source dataspace in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
hsize_t srcdims_para[1] = {nDimx};
|
||||
hsize_t srcdimsmax_para[1] = {H5S_UNLIMITED};
|
||||
hid_t srcDataspace_para = H5Screate_simple(1, srcdims_para, srcdimsmax_para);
|
||||
if (srcDataspace_para < 0)
|
||||
return CloseFileOnError(fd,
|
||||
std::string("Could not create source dataspace (parameters) in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
|
||||
//mapping
|
||||
if (H5Pset_virtual(dcpl, vdsDataspace, relative_srcFileName.c_str(),
|
||||
srcDatasetName.c_str(), srcDataspace) < 0) {
|
||||
FILE_LOG(logERROR) << "Could not set mapping for paramter 1";
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
|
||||
for (unsigned int k = 0; k < parameterNames.size(); ++k) {
|
||||
if (H5Pset_virtual(dcpl_para[k], vdsDataspace_para, relative_srcFileName.c_str(),
|
||||
parameterNames[k], srcDataspace_para) < 0) {
|
||||
FILE_LOG(logERROR) << "Could not set mapping for paramter " << k;
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//H5Sclose(srcDataspace);
|
||||
//H5Sclose(srcDataspace_para);
|
||||
offset[2] += nDimz;
|
||||
if (offset[2] >= (numDetz * nDimz)) {
|
||||
offset[2] = 0;
|
||||
offset[1] += nDimy;
|
||||
}
|
||||
offset_para[1]++;
|
||||
//fill values
|
||||
hid_t dcpl = H5Pcreate (H5P_DATASET_CREATE);
|
||||
if (dcpl < 0)
|
||||
throw RuntimeError("Could not create file creation properties in virtual file " + virtualFileName);
|
||||
int fill_value = -1;
|
||||
if (H5Pset_fill_value (dcpl, GetDataTypeinC(dataType), &fill_value) < 0)
|
||||
throw RuntimeError("Could not create fill value in virtual file " + virtualFileName);
|
||||
hid_t dcpl_para[parameterNames.size()];
|
||||
for (unsigned int i = 0; i < parameterNames.size(); ++i) {
|
||||
dcpl_para[i] = H5Pcreate (H5P_DATASET_CREATE);
|
||||
if (dcpl_para[i] < 0)
|
||||
throw RuntimeError("Could not create file creation properties (parameters) in virtual file " + virtualFileName);
|
||||
if (H5Pset_fill_value (dcpl_para[i], GetDataTypeinC(parameterDataTypes[i]), &fill_value) < 0)
|
||||
throw RuntimeError("Could not create fill value (parameters) in virtual file " + virtualFileName);
|
||||
}
|
||||
framesSaved += nDimx;
|
||||
|
||||
//hyperslab
|
||||
int numMajorHyperslab = numf/maxFramesPerFile;
|
||||
if (numf%maxFramesPerFile) numMajorHyperslab++;
|
||||
uint64_t framesSaved = 0;
|
||||
for (int j = 0; j < numMajorHyperslab; j++) {
|
||||
|
||||
uint64_t nDimx = ((numf - framesSaved) > maxFramesPerFile)
|
||||
? maxFramesPerFile : (numf-framesSaved);
|
||||
hsize_t offset[3] = {framesSaved, 0, 0};
|
||||
hsize_t count[3] = {nDimx, nDimy, nDimz};
|
||||
hsize_t offset_para[2] = {framesSaved, 0};
|
||||
hsize_t count_para[2] = {nDimx, 1};
|
||||
|
||||
for (int i = 0; i < numDety * numDetz; ++i) {
|
||||
|
||||
//setect hyperslabs
|
||||
if (H5Sselect_hyperslab (vdsDataspace, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) {
|
||||
throw RuntimeError("Could not select hyperslab");
|
||||
}
|
||||
if (H5Sselect_hyperslab (vdsDataspace_para, H5S_SELECT_SET,
|
||||
offset_para, NULL, count_para, NULL) < 0) {
|
||||
throw RuntimeError("Could not select hyperslab for parameters");
|
||||
}
|
||||
|
||||
//source file name
|
||||
std::string srcFileName = HDF5FileStatic::CreateFileName(fpath, fnameprefix, findex,
|
||||
j, dindex, numunits, i);
|
||||
|
||||
FILE_LOG(logERROR) << srcFileName;
|
||||
// find relative path
|
||||
std::string relative_srcFileName = srcFileName;
|
||||
{
|
||||
size_t i = srcFileName.rfind('/', srcFileName.length());
|
||||
if (i != std::string::npos)
|
||||
relative_srcFileName = (srcFileName.substr(i+1, srcFileName.length() - i));
|
||||
}
|
||||
|
||||
//source dataset name
|
||||
std::ostringstream osfn;
|
||||
osfn << "/data";
|
||||
if (frindexenable) osfn << "_f" << std::setfill('0') << std::setw(12) << j;
|
||||
std::string srcDatasetName = osfn.str();
|
||||
|
||||
//source dataspace
|
||||
hsize_t srcdims[3] = {nDimx, nDimy, nDimz};
|
||||
hsize_t srcdimsmax[3] = {H5S_UNLIMITED, nDimy, nDimz};
|
||||
hid_t srcDataspace = H5Screate_simple(3, srcdims, srcdimsmax);
|
||||
if (srcDataspace < 0)
|
||||
throw RuntimeError("Could not create source dataspace in virtual file " + virtualFileName);
|
||||
hsize_t srcdims_para[1] = {nDimx};
|
||||
hsize_t srcdimsmax_para[1] = {H5S_UNLIMITED};
|
||||
hid_t srcDataspace_para = H5Screate_simple(1, srcdims_para, srcdimsmax_para);
|
||||
if (srcDataspace_para < 0)
|
||||
throw RuntimeError("Could not create source dataspace (parameters) in virtual file " + virtualFileName);
|
||||
|
||||
//mapping
|
||||
if (H5Pset_virtual(dcpl, vdsDataspace, relative_srcFileName.c_str(),
|
||||
srcDatasetName.c_str(), srcDataspace) < 0) {
|
||||
throw RuntimeError("Could not set mapping for paramter 1");
|
||||
}
|
||||
|
||||
for (unsigned int k = 0; k < parameterNames.size(); ++k) {
|
||||
if (H5Pset_virtual(dcpl_para[k], vdsDataspace_para, relative_srcFileName.c_str(),
|
||||
parameterNames[k], srcDataspace_para) < 0) {
|
||||
throw RuntimeError("Could not set mapping for paramter " + std::to_string(k));
|
||||
}
|
||||
}
|
||||
|
||||
//H5Sclose(srcDataspace);
|
||||
//H5Sclose(srcDataspace_para);
|
||||
offset[2] += nDimz;
|
||||
if (offset[2] >= (numDetz * nDimz)) {
|
||||
offset[2] = 0;
|
||||
offset[1] += nDimy;
|
||||
}
|
||||
offset_para[1]++;
|
||||
}
|
||||
framesSaved += nDimx;
|
||||
}
|
||||
|
||||
//dataset
|
||||
std::string virtualDatasetName = srcDataseName;
|
||||
hid_t vdsdataset = H5Dcreate2 (fd, virtualDatasetName.c_str(),
|
||||
GetDataTypeinC(dataType), vdsDataspace, H5P_DEFAULT, dcpl, H5P_DEFAULT);
|
||||
if (vdsdataset < 0)
|
||||
throw RuntimeError("Could not create virutal dataset in virtual file " + virtualFileName);
|
||||
|
||||
|
||||
//virtual parameter dataset
|
||||
for (unsigned int i = 0; i < parameterNames.size(); ++i) {
|
||||
hid_t vdsdataset_para = H5Dcreate2 (fd,
|
||||
parameterNames[i],
|
||||
GetDataTypeinC(parameterDataTypes[i]), vdsDataspace_para,
|
||||
H5P_DEFAULT, dcpl_para[i], H5P_DEFAULT);
|
||||
if (vdsdataset_para < 0)
|
||||
throw RuntimeError("Could not create virutal dataset (parameters) in virtual file " + virtualFileName);
|
||||
}
|
||||
|
||||
//close
|
||||
H5Fclose(fd);
|
||||
fd = 0;
|
||||
|
||||
//link
|
||||
LinkVirtualInMaster(masterFileName, virtualFileName, virtualDatasetName, parameterNames);
|
||||
} catch (const RuntimeError &e) {
|
||||
if (fd > 0)
|
||||
H5Fclose(fd);
|
||||
fd = 0;
|
||||
}
|
||||
if (error)
|
||||
return CloseFileOnError(fd,
|
||||
std::string("Could not map files in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
|
||||
//dataset
|
||||
std::string virtualDatasetName = srcDataseName;
|
||||
hid_t vdsdataset = H5Dcreate2 (fd, virtualDatasetName.c_str(),
|
||||
GetDataTypeinC(dataType), vdsDataspace, H5P_DEFAULT, dcpl, H5P_DEFAULT);
|
||||
if (vdsdataset < 0)
|
||||
return CloseFileOnError(fd,
|
||||
std::string("Could not create virutal dataset in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
|
||||
|
||||
//virtual parameter dataset
|
||||
for (unsigned int i = 0; i < parameterNames.size(); ++i) {
|
||||
hid_t vdsdataset_para = H5Dcreate2 (fd,
|
||||
parameterNames[i],
|
||||
GetDataTypeinC(parameterDataTypes[i]), vdsDataspace_para,
|
||||
H5P_DEFAULT, dcpl_para[i], H5P_DEFAULT);
|
||||
if (vdsdataset_para < 0)
|
||||
return CloseFileOnError(fd,
|
||||
std::string("Could not create virutal dataset (parameters) in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
}
|
||||
|
||||
//close
|
||||
H5Fclose(fd); fd = 0;
|
||||
|
||||
//link
|
||||
return LinkVirtualInMaster(masterFileName, virtualFileName, virtualDatasetName, parameterNames);
|
||||
}
|
||||
|
||||
|
||||
@ -809,10 +756,9 @@ public:
|
||||
* @param nDimx Number of objects in x dimension
|
||||
* @param nDimy Number of objects in y dimension
|
||||
* @param nDimz Number of objects in z dimension
|
||||
* @returns 0 for success and 1 for fail
|
||||
*/
|
||||
template <typename T>
|
||||
static int CopyVirtualFile(T datatype, bool owenable, std::string oldFileName, std::string oldDatasetName,
|
||||
static void CopyVirtualFile(T datatype, bool owenable, std::string oldFileName, std::string oldDatasetName,
|
||||
std::string newFileName, std::string newDatasetName, int rank,
|
||||
uint64_t nDimx, uint32_t nDimy, uint32_t nDimz=0)
|
||||
{
|
||||
@ -825,8 +771,7 @@ public:
|
||||
data_out = (T*)malloc(sizeof(T)*(nDimx*nDimy*nDimz));
|
||||
break;
|
||||
default:
|
||||
FILE_LOG(logERROR) << "Invalid rank. Options: 2 or 3";
|
||||
return 0;
|
||||
throw RuntimeError("Invalid rank. Options: 2 or 3");
|
||||
}
|
||||
if (datatype == PredType::STD_U16LE) {
|
||||
FILE_LOG(logINFO) << "datatype:16";
|
||||
@ -837,8 +782,7 @@ public:
|
||||
} else if (datatype == PredType::STD_U8LE) {
|
||||
FILE_LOG(logINFO) << "datatype:8";
|
||||
} else {
|
||||
FILE_LOG(logERROR) << "Unknown datatype: " << datatype;
|
||||
return 1;
|
||||
throw RuntimeError("Unknown datatype:" + std::to_string(datatype));
|
||||
}
|
||||
FILE_LOG(logINFO) << "owenable:" << (owenable?1:0) << std::endl
|
||||
<< "oldFileName:" << oldFileName << std::endl
|
||||
@ -888,15 +832,13 @@ public:
|
||||
newfd->close();
|
||||
oldfd->close();
|
||||
} catch(const Exception& error){
|
||||
FILE_LOG(logERROR) << "Could not copy virtual files";
|
||||
error.printErrorStack();
|
||||
free(data_out);
|
||||
oldfd->close();
|
||||
newfd->close();
|
||||
return 1;
|
||||
throw RuntimeError("Could not copy virtual files");
|
||||
}
|
||||
free(data_out);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -908,89 +850,80 @@ public:
|
||||
* @param virtualfname virtual file name
|
||||
* @param virtualDatasetname virtual dataset name
|
||||
* @param parameterNames parameter names
|
||||
* @returns 0 for success and 1 for fail
|
||||
*/
|
||||
static int LinkVirtualInMaster(std::string masterFileName, std::string virtualfname,
|
||||
static void LinkVirtualInMaster(std::string masterFileName, std::string virtualfname,
|
||||
std::string virtualDatasetname, std::vector <const char*> parameterNames) {
|
||||
char linkname[100];
|
||||
hid_t vfd = 0;
|
||||
|
||||
hid_t dfal = H5Pcreate (H5P_FILE_ACCESS);
|
||||
if (dfal < 0)
|
||||
return CloseFileOnError( vfd, std::string("Could not create file access property for link\n"));
|
||||
if (H5Pset_fclose_degree (dfal, H5F_CLOSE_STRONG) < 0)
|
||||
return CloseFileOnError( vfd, std::string("Could not set strong file close degree for link\n"));
|
||||
try {
|
||||
hid_t dfal = H5Pcreate (H5P_FILE_ACCESS);
|
||||
if (dfal < 0)
|
||||
throw RuntimeError("Could not create file access property for link");
|
||||
if (H5Pset_fclose_degree (dfal, H5F_CLOSE_STRONG) < 0)
|
||||
throw RuntimeError("Could not set strong file close degree for link");
|
||||
|
||||
//open master file
|
||||
hid_t mfd = H5Fopen( masterFileName.c_str(), H5F_ACC_RDWR, dfal);
|
||||
if (mfd < 0)
|
||||
return CloseFileOnError( vfd, std::string("Could not open master file\n"));
|
||||
//open master file
|
||||
hid_t mfd = H5Fopen( masterFileName.c_str(), H5F_ACC_RDWR, dfal);
|
||||
if (mfd < 0)
|
||||
throw RuntimeError("Could not open master file");
|
||||
|
||||
//open virtual file
|
||||
vfd = H5Fopen( virtualfname.c_str(), H5F_ACC_RDWR, dfal);
|
||||
if (vfd < 0) {
|
||||
H5Fclose(mfd); mfd = 0;
|
||||
return CloseFileOnError( vfd, std::string("Could not open virtual file\n"));
|
||||
}
|
||||
|
||||
// find relative path
|
||||
std::string relative_virtualfname = virtualfname;
|
||||
{
|
||||
size_t i = virtualfname.rfind('/', virtualfname.length());
|
||||
if (i != std::string::npos)
|
||||
relative_virtualfname = (virtualfname.substr(i+1, virtualfname.length() - i));
|
||||
}
|
||||
|
||||
//**data dataset**
|
||||
hid_t vdset = H5Dopen2( vfd, virtualDatasetname.c_str(), H5P_DEFAULT);
|
||||
if (vdset < 0) {
|
||||
H5Fclose(mfd);
|
||||
return CloseFileOnError( vfd, std::string("Could not open virtual data dataset\n"));
|
||||
}
|
||||
sprintf(linkname, "/entry/data/%s",virtualDatasetname.c_str());
|
||||
if(H5Lcreate_external( relative_virtualfname.c_str(), virtualDatasetname.c_str(),
|
||||
mfd, linkname, H5P_DEFAULT, H5P_DEFAULT) < 0) {
|
||||
H5Fclose(mfd); mfd = 0;
|
||||
return CloseFileOnError( vfd, std::string("Could not create link to data dataset\n"));
|
||||
}
|
||||
H5Dclose(vdset);
|
||||
|
||||
//**paramter datasets**
|
||||
for (unsigned int i = 0; i < parameterNames.size(); ++i){
|
||||
hid_t vdset_para = H5Dopen2( vfd, (std::string (parameterNames[i])).c_str(), H5P_DEFAULT);
|
||||
if (vdset_para < 0) {
|
||||
//open virtual file
|
||||
vfd = H5Fopen( virtualfname.c_str(), H5F_ACC_RDWR, dfal);
|
||||
if (vfd < 0) {
|
||||
H5Fclose(mfd); mfd = 0;
|
||||
return CloseFileOnError( vfd, std::string("Could not open virtual parameter dataset to create link\n"));
|
||||
throw RuntimeError("Could not open virtual file");
|
||||
}
|
||||
sprintf(linkname, "/entry/data/%s",(std::string (parameterNames[i])).c_str());
|
||||
|
||||
if(H5Lcreate_external( relative_virtualfname.c_str(), (std::string (parameterNames[i])).c_str(),
|
||||
mfd, linkname, H5P_DEFAULT, H5P_DEFAULT) < 0) {
|
||||
// find relative path
|
||||
std::string relative_virtualfname = virtualfname;
|
||||
{
|
||||
size_t i = virtualfname.rfind('/', virtualfname.length());
|
||||
if (i != std::string::npos)
|
||||
relative_virtualfname = (virtualfname.substr(i+1, virtualfname.length() - i));
|
||||
}
|
||||
|
||||
//**data dataset**
|
||||
hid_t vdset = H5Dopen2( vfd, virtualDatasetname.c_str(), H5P_DEFAULT);
|
||||
if (vdset < 0) {
|
||||
H5Fclose(mfd);
|
||||
throw RuntimeError("Could not open virtual data dataset");
|
||||
}
|
||||
sprintf(linkname, "/entry/data/%s",virtualDatasetname.c_str());
|
||||
if(H5Lcreate_external( relative_virtualfname.c_str(), virtualDatasetname.c_str(),
|
||||
mfd, linkname, H5P_DEFAULT, H5P_DEFAULT) < 0) {
|
||||
H5Fclose(mfd); mfd = 0;
|
||||
return CloseFileOnError( vfd, std::string("Could not create link to virtual parameter dataset\n"));
|
||||
throw RuntimeError("Could not create link to data dataset");
|
||||
}
|
||||
}
|
||||
H5Dclose(vdset);
|
||||
|
||||
H5Fclose(mfd); mfd = 0;
|
||||
H5Fclose(vfd); vfd = 0;
|
||||
return 0;
|
||||
//**paramter datasets**
|
||||
for (unsigned int i = 0; i < parameterNames.size(); ++i){
|
||||
hid_t vdset_para = H5Dopen2( vfd, (std::string (parameterNames[i])).c_str(), H5P_DEFAULT);
|
||||
if (vdset_para < 0) {
|
||||
H5Fclose(mfd); mfd = 0;
|
||||
throw RuntimeError("Could not open virtual parameter dataset to create link");
|
||||
}
|
||||
sprintf(linkname, "/entry/data/%s",(std::string (parameterNames[i])).c_str());
|
||||
|
||||
if(H5Lcreate_external( relative_virtualfname.c_str(), (std::string (parameterNames[i])).c_str(),
|
||||
mfd, linkname, H5P_DEFAULT, H5P_DEFAULT) < 0) {
|
||||
H5Fclose(mfd); mfd = 0;
|
||||
throw RuntimeError("Could not create link to virtual parameter dataset");
|
||||
}
|
||||
}
|
||||
|
||||
H5Fclose(mfd); mfd = 0;
|
||||
H5Fclose(vfd); vfd = 0;
|
||||
} catch () {
|
||||
if(vfd > 0)
|
||||
H5Fclose(vfd);
|
||||
vfd = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Print Error msg and Close File and called on error
|
||||
* @returns 1 for fail
|
||||
*/
|
||||
static int CloseFileOnError(hid_t& fd, const std::string msg) {
|
||||
FILE_LOG(logERROR) << msg;
|
||||
if(fd > 0)
|
||||
H5Fclose(fd);
|
||||
fd = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Data type in C
|
||||
* @param dtype datatype in C++
|
||||
|
@ -17,22 +17,16 @@ class slsDetectorDefs;
|
||||
|
||||
class Implementation : private virtual slsDetectorDefs {
|
||||
public:
|
||||
Implementation();
|
||||
Implementation(const detectorType d);
|
||||
virtual ~Implementation();
|
||||
|
||||
|
||||
/**************************************************
|
||||
* *
|
||||
* Configuration Parameters *
|
||||
* *
|
||||
* ************************************************/
|
||||
/**
|
||||
* Set receiver type. It is the first function called by the client when
|
||||
* connecting to receiver
|
||||
* @param d detector type
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int setDetectorType(const detectorType d);
|
||||
|
||||
void setDetectorType(const detectorType d);
|
||||
int *getMultiDetectorSize() const;
|
||||
void setMultiDetectorSize(const int *size);
|
||||
int getDetectorPositionId() const;
|
||||
@ -42,7 +36,7 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
bool getSilentMode() const;
|
||||
void setSilentMode(const bool i);
|
||||
uint32_t getFifoDepth() const;
|
||||
int setFifoDepth(const uint32_t i);
|
||||
void setFifoDepth(const uint32_t i);
|
||||
frameDiscardPolicy getFrameDiscardPolicy() const;
|
||||
void setFrameDiscardPolicy(const frameDiscardPolicy i);
|
||||
bool getFramePaddingEnable() const;
|
||||
@ -81,13 +75,13 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
uint64_t getFramesCaught() const;
|
||||
uint64_t getAcquisitionIndex() const;
|
||||
std::vector<uint64_t> getNumMissingPackets() const;
|
||||
int startReceiver(std::string& err);
|
||||
void startReceiver();
|
||||
void setStoppedFlag(bool stopped);
|
||||
void stopReceiver();
|
||||
void startReadout();
|
||||
void shutDownUDPSockets();
|
||||
void closeFiles();
|
||||
int restreamStop();
|
||||
void restreamStop();
|
||||
|
||||
|
||||
/**************************************************
|
||||
@ -97,7 +91,7 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
* ************************************************/
|
||||
int getNumberofUDPInterfaces() const;
|
||||
/* [Jungfrau] */
|
||||
int setNumberofUDPInterfaces(const int n);
|
||||
void setNumberofUDPInterfaces(const int n);
|
||||
std::string getEthernetInterface() const;
|
||||
void setEthernetInterface(const std::string &c);
|
||||
std::string getEthernetInterface2() const;
|
||||
@ -109,7 +103,7 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
/* [Eiger][Jungfrau] */
|
||||
void setUDPPortNumber2(const uint32_t i);
|
||||
int64_t getUDPSocketBufferSize() const;
|
||||
int setUDPSocketBufferSize(const int64_t s);
|
||||
void setUDPSocketBufferSize(const int64_t s);
|
||||
int64_t getActualUDPSocketBufferSize() const;
|
||||
|
||||
|
||||
@ -119,10 +113,10 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
* *
|
||||
* ************************************************/
|
||||
bool getDataStreamEnable() const;
|
||||
int setDataStreamEnable(const bool enable);
|
||||
void setDataStreamEnable(const bool enable);
|
||||
uint32_t getStreamingFrequency() const;
|
||||
/* 0 for timer */
|
||||
int setStreamingFrequency(const uint32_t freq);
|
||||
void setStreamingFrequency(const uint32_t freq);
|
||||
uint32_t getStreamingTimer() const;
|
||||
void setStreamingTimer(const uint32_t time_in_ms);
|
||||
uint32_t getStreamingPort() const;
|
||||
@ -151,26 +145,26 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
void setSubPeriod(const uint64_t i);
|
||||
uint32_t getNumberofAnalogSamples() const;
|
||||
/**[Ctb][Moench] */
|
||||
int setNumberofAnalogSamples(const uint32_t i);
|
||||
void setNumberofAnalogSamples(const uint32_t i);
|
||||
uint32_t getNumberofDigitalSamples() const;
|
||||
/**[Ctb] */
|
||||
int setNumberofDigitalSamples(const uint32_t i);
|
||||
void setNumberofDigitalSamples(const uint32_t i);
|
||||
uint32_t getDynamicRange() const;
|
||||
int setDynamicRange(const uint32_t i);
|
||||
void setDynamicRange(const uint32_t i);
|
||||
ROI getROI() const;
|
||||
/* [Gotthard] */
|
||||
int setROI(ROI arg);
|
||||
void setROI(ROI arg);
|
||||
bool getTenGigaEnable() const;
|
||||
/* [Eiger][Ctb] */
|
||||
int setTenGigaEnable(const bool b);
|
||||
void setTenGigaEnable(const bool b);
|
||||
int getFlippedDataX() const;
|
||||
void setFlippedDataX(int enable = -1);
|
||||
bool getGapPixelsEnable() const;
|
||||
/* [Eiger] */
|
||||
int setGapPixelsEnable(const bool b);
|
||||
void setGapPixelsEnable(const bool b);
|
||||
bool getQuad() const;
|
||||
/* [Eiger] */
|
||||
int setQuad(const bool b);
|
||||
void setQuad(const bool b);
|
||||
bool getActivate() const;
|
||||
/** [Eiger] If deactivated, receiver will create dummy data if deactivated padding is enabled (as it will receive nothing from detector) */
|
||||
bool setActivate(const bool enable);
|
||||
@ -182,13 +176,13 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
void setReadNLines(const int value);
|
||||
readoutMode getReadoutMode() const;
|
||||
/* [Ctb] */
|
||||
int setReadoutMode(const readoutMode f);
|
||||
void setReadoutMode(const readoutMode f);
|
||||
uint32_t getADCEnableMask() const;
|
||||
/* [Ctb][Moench] */
|
||||
int setADCEnableMask(const uint32_t mask);
|
||||
void setADCEnableMask(const uint32_t mask);
|
||||
uint32_t getTenGigaADCEnableMask() const;
|
||||
/* [Ctb][Moench] */
|
||||
int setTenGigaADCEnableMask(const uint32_t mask);
|
||||
void setTenGigaADCEnableMask(const uint32_t mask);
|
||||
std::vector<int> getDbitList() const;
|
||||
/* [Ctb] */
|
||||
void setDbitList(const std::vector<int> v);
|
||||
@ -215,11 +209,11 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
void InitializeMembers();
|
||||
void SetLocalNetworkParameters();
|
||||
void SetThreadPriorities();
|
||||
int SetupFifoStructure();
|
||||
void SetupFifoStructure();
|
||||
|
||||
void ResetParametersforNewAcquisition();
|
||||
int CreateUDPSockets();
|
||||
int SetupWriter();
|
||||
void CreateUDPSockets();
|
||||
void SetupWriter();
|
||||
void StartRunning();
|
||||
|
||||
|
||||
|
@ -105,15 +105,13 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
||||
/**
|
||||
* Set thread priority
|
||||
* @priority priority
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int SetThreadPriority(int priority);
|
||||
void SetThreadPriority(int priority);
|
||||
|
||||
/**
|
||||
* Creates UDP Sockets
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int CreateUDPSockets();
|
||||
void CreateUDPSockets();
|
||||
|
||||
/**
|
||||
* Shuts down and deletes UDP Sockets
|
||||
@ -124,9 +122,8 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
||||
* Create & closes a dummy UDP socket
|
||||
* to set & get actual buffer size
|
||||
* @param s UDP socket buffer size to be set
|
||||
* @return OK or FAIL of dummy socket creation
|
||||
*/
|
||||
int CreateDummySocketForUDPSocketBufferSize(int64_t s);
|
||||
void CreateDummySocketForUDPSocketBufferSize(int64_t s);
|
||||
|
||||
/**
|
||||
* Set hard coded (calculated but not from detector) row and column
|
||||
|
@ -66,9 +66,8 @@ class ThreadObject : private virtual slsDetectorDefs {
|
||||
|
||||
/**
|
||||
* Create Thread, sets semaphore, alive and killThread
|
||||
* @return OK if successful, else FAIL
|
||||
*/
|
||||
int CreateThread();
|
||||
void CreateThread();
|
||||
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user