mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-06 01:50:40 +02:00
Merge branch 'rxr' into developer
This commit is contained in:
commit
f178b0da39
Binary file not shown.
@ -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:
|
||||
|
@ -42,20 +42,18 @@ slsDetectorDefs::fileFormat BinaryFile::GetFileType() {
|
||||
}
|
||||
|
||||
|
||||
int BinaryFile::CreateFile() {
|
||||
void BinaryFile::CreateFile() {
|
||||
numFramesInFile = 0;
|
||||
numActualPacketsInFile = 0;
|
||||
|
||||
currentFileName = BinaryFileStatic::CreateFileName(*filePath, *fileNamePrefix, *fileIndex,
|
||||
subFileIndex, *detIndex, *numUnitsPerDetector, index);
|
||||
|
||||
if (BinaryFileStatic::CreateDataFile(filefd, *overWriteEnable, currentFileName, FILE_BUFFER_SIZE) == FAIL)
|
||||
return FAIL;
|
||||
BinaryFileStatic::CreateDataFile(filefd, *overWriteEnable, currentFileName, FILE_BUFFER_SIZE);
|
||||
|
||||
if(!(*silentMode)) {
|
||||
FILE_LOG(logINFO) << "[" << *udpPortNumber << "]: Binary File created: " << currentFileName;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
void BinaryFile::CloseCurrentFile() {
|
||||
@ -68,7 +66,7 @@ void BinaryFile::CloseAllFiles() {
|
||||
BinaryFileStatic::CloseDataFile(masterfd);
|
||||
}
|
||||
|
||||
int BinaryFile::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) {
|
||||
void BinaryFile::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) {
|
||||
// check if maxframesperfile = 0 for infinite
|
||||
if ((*maxFramesPerFile) && (numFramesInFile >= (*maxFramesPerFile))) {
|
||||
CloseCurrentFile();
|
||||
@ -107,14 +105,12 @@ int BinaryFile::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_
|
||||
|
||||
// if write error
|
||||
if (ret != buffersize) {
|
||||
FILE_LOG(logERROR) << index << " Error: Write to file failed for image number " << fnum;
|
||||
return FAIL;
|
||||
throw sls::RuntimeError(std::to_string(index) + " : Write to file failed for image number " + std::to_string(fnum));
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
int BinaryFile::CreateMasterFile(bool mfwenable, masterAttributes& attr) {
|
||||
void BinaryFile::CreateMasterFile(bool mfwenable, masterAttributes& attr) {
|
||||
//beginning of every acquisition
|
||||
numFramesInFile = 0;
|
||||
numActualPacketsInFile = 0;
|
||||
@ -126,10 +122,9 @@ int BinaryFile::CreateMasterFile(bool mfwenable, masterAttributes& attr) {
|
||||
FILE_LOG(logINFO) << "Master File: " << masterFileName;
|
||||
}
|
||||
attr.version = BINARY_WRITER_VERSION;
|
||||
return BinaryFileStatic::CreateMasterDataFile(masterfd, masterFileName,
|
||||
BinaryFileStatic::CreateMasterDataFile(masterfd, masterFileName,
|
||||
*overWriteEnable, attr);
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -473,11 +473,11 @@ int ClientInterface::set_detector_type(Interface &socket) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (receiver == nullptr) {
|
||||
receiver = sls::make_unique<Implementation>();
|
||||
}
|
||||
myDetectorType = arg;
|
||||
if (impl()->setDetectorType(myDetectorType) == FAIL) {
|
||||
try {
|
||||
myDetectorType = GENERIC;
|
||||
receiver = sls::make_unique<Implementation>(arg);
|
||||
myDetectorType = arg;
|
||||
} catch (...) {
|
||||
throw RuntimeError("Could not set detector type");
|
||||
}
|
||||
|
||||
@ -525,8 +525,11 @@ int ClientInterface::set_roi(Interface &socket) {
|
||||
functionNotImplemented();
|
||||
|
||||
VerifyIdle(socket);
|
||||
if (impl()->setROI(arg) == FAIL)
|
||||
try {
|
||||
impl()->setROI(arg);
|
||||
} catch(const RuntimeError &e) {
|
||||
throw RuntimeError("Could not set ROI");
|
||||
}
|
||||
return socket.Send(OK);
|
||||
}
|
||||
|
||||
@ -543,7 +546,11 @@ int ClientInterface::set_num_analog_samples(Interface &socket) {
|
||||
if (myDetectorType != CHIPTESTBOARD && myDetectorType != MOENCH) {
|
||||
functionNotImplemented();
|
||||
}
|
||||
ret = impl()->setNumberofAnalogSamples(value);
|
||||
try {
|
||||
impl()->setNumberofAnalogSamples(value);
|
||||
} catch(const RuntimeError &e) {
|
||||
throw RuntimeError("Could not set num analog samples to " + std::to_string(value) + " due to fifo structure memory allocation.");
|
||||
}
|
||||
|
||||
return socket.Send(OK);
|
||||
}
|
||||
@ -554,7 +561,11 @@ int ClientInterface::set_num_digital_samples(Interface &socket) {
|
||||
if (myDetectorType != CHIPTESTBOARD && myDetectorType != MOENCH) {
|
||||
functionNotImplemented();
|
||||
}
|
||||
ret = impl()->setNumberofDigitalSamples(value);
|
||||
try {
|
||||
impl()->setNumberofDigitalSamples(value);
|
||||
} catch(const RuntimeError &e) {
|
||||
throw RuntimeError("Could not set num digital samples to " + std::to_string(value) + " due to fifo structure memory allocation.");
|
||||
}
|
||||
return socket.Send(OK);
|
||||
}
|
||||
|
||||
@ -613,8 +624,9 @@ int ClientInterface::set_dynamic_range(Interface &socket) {
|
||||
if (!exists) {
|
||||
modeNotImplemented("Dynamic range", dr);
|
||||
} else {
|
||||
ret = impl()->setDynamicRange(dr);
|
||||
if (ret == FAIL) {
|
||||
try {
|
||||
impl()->setDynamicRange(dr);
|
||||
} catch(const RuntimeError &e) {
|
||||
throw RuntimeError("Could not allocate memory for fifo or "
|
||||
"could not start listening/writing threads");
|
||||
}
|
||||
@ -631,10 +643,7 @@ int ClientInterface::set_streaming_frequency(Interface &socket) {
|
||||
if (index >= 0) {
|
||||
VerifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting streaming frequency: " << index;
|
||||
ret = impl()->setStreamingFrequency(index);
|
||||
if (ret == FAIL) {
|
||||
throw RuntimeError("Could not allocate memory for listening fifo");
|
||||
}
|
||||
impl()->setStreamingFrequency(index);
|
||||
}
|
||||
int retval = impl()->getStreamingFrequency();
|
||||
validate(index, retval, "set streaming frequency", DEC);
|
||||
@ -650,11 +659,7 @@ int ClientInterface::get_status(Interface &socket) {
|
||||
int ClientInterface::start_receiver(Interface &socket) {
|
||||
if (impl()->getStatus() == IDLE) {
|
||||
FILE_LOG(logDEBUG1) << "Starting Receiver";
|
||||
std::string err;
|
||||
ret = impl()->startReceiver(err);
|
||||
if (ret == FAIL) {
|
||||
throw RuntimeError(err);
|
||||
}
|
||||
impl()->startReceiver();
|
||||
}
|
||||
return socket.Send(OK);
|
||||
}
|
||||
@ -797,7 +802,11 @@ int ClientInterface::enable_tengiga(Interface &socket) {
|
||||
if (val >= 0) {
|
||||
VerifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting 10GbE:" << val;
|
||||
ret = impl()->setTenGigaEnable(val);
|
||||
try {
|
||||
impl()->setTenGigaEnable(val);
|
||||
} catch(const RuntimeError &e) {
|
||||
throw RuntimeError("Could not set 10GbE.");
|
||||
}
|
||||
}
|
||||
int retval = impl()->getTenGigaEnable();
|
||||
validate(val, retval, "set 10GbE", DEC);
|
||||
@ -810,7 +819,11 @@ int ClientInterface::set_fifo_depth(Interface &socket) {
|
||||
if (value >= 0) {
|
||||
VerifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting fifo depth:" << value;
|
||||
impl()->setFifoDepth(value);
|
||||
try {
|
||||
impl()->setFifoDepth(value);
|
||||
} catch(const RuntimeError &e) {
|
||||
throw RuntimeError("Could not set fifo depth due to fifo structure memory allocation.");
|
||||
}
|
||||
}
|
||||
int retval = impl()->getFifoDepth();
|
||||
validate(value, retval, std::string("set fifo depth"), DEC);
|
||||
@ -839,7 +852,11 @@ int ClientInterface::set_data_stream_enable(Interface &socket) {
|
||||
if (index >= 0) {
|
||||
VerifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting data stream enable:" << index;
|
||||
impl()->setDataStreamEnable(index);
|
||||
try {
|
||||
impl()->setDataStreamEnable(index);
|
||||
} catch(const RuntimeError &e) {
|
||||
throw RuntimeError("Could not set data stream enable to " + std::to_string(index));
|
||||
}
|
||||
}
|
||||
auto retval = static_cast<int>(impl()->getDataStreamEnable());
|
||||
validate(index, retval, "set data stream enable", DEC);
|
||||
@ -969,7 +986,11 @@ int ClientInterface::enable_gap_pixels(Interface &socket) {
|
||||
if (enable >= 0) {
|
||||
VerifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting gap pixels enable:" << enable;
|
||||
impl()->setGapPixelsEnable(static_cast<bool>(enable));
|
||||
try {
|
||||
impl()->setGapPixelsEnable(static_cast<bool>(enable));
|
||||
} catch(const RuntimeError &e) {
|
||||
throw RuntimeError("Could not set gap pixels enable to " + std::to_string(enable));
|
||||
}
|
||||
}
|
||||
auto retval = static_cast<int>(impl()->getGapPixelsEnable());
|
||||
validate(enable, retval, "set gap pixels enable", DEC);
|
||||
@ -1013,10 +1034,7 @@ int ClientInterface::set_udp_socket_buffer_size(Interface &socket) {
|
||||
if (index >= 0) {
|
||||
VerifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting UDP Socket Buffer size: " << index;
|
||||
if (impl()->setUDPSocketBufferSize(index) == FAIL) {
|
||||
throw RuntimeError(
|
||||
"Could not create dummy UDP Socket to test buffer size");
|
||||
}
|
||||
impl()->setUDPSocketBufferSize(index);
|
||||
}
|
||||
int64_t retval = impl()->getUDPSocketBufferSize();
|
||||
if (index != 0)
|
||||
@ -1127,7 +1145,11 @@ int ClientInterface::set_readout_mode(Interface &socket) {
|
||||
if (arg >= 0) {
|
||||
VerifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting readout mode: " << arg;
|
||||
impl()->setReadoutMode(arg);
|
||||
try {
|
||||
impl()->setReadoutMode(arg);
|
||||
} catch(const RuntimeError &e) {
|
||||
throw RuntimeError("Could not set read out mode due to fifo memory allocation.");
|
||||
}
|
||||
}
|
||||
auto retval = impl()->getReadoutMode();
|
||||
validate(static_cast<int>(arg), static_cast<int>(retval),
|
||||
@ -1140,7 +1162,11 @@ int ClientInterface::set_adc_mask(Interface &socket) {
|
||||
auto arg = socket.Receive<uint32_t>();
|
||||
VerifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting 1Gb ADC enable mask: " << arg;
|
||||
impl()->setADCEnableMask(arg);
|
||||
try {
|
||||
impl()->setADCEnableMask(arg);
|
||||
} catch(const RuntimeError &e) {
|
||||
throw RuntimeError("Could not set adc enable mask due to fifo memory allcoation");
|
||||
}
|
||||
auto retval = impl()->getADCEnableMask();
|
||||
if (retval != arg) {
|
||||
std::ostringstream os;
|
||||
@ -1190,10 +1216,11 @@ int ClientInterface::set_quad_type(Interface &socket) {
|
||||
if (quadEnable >= 0) {
|
||||
VerifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting quad:" << quadEnable;
|
||||
ret = impl()->setQuad(quadEnable == 0 ? false : true);
|
||||
if (ret == FAIL) {
|
||||
throw RuntimeError("Could not set Quad due to fifo structure");
|
||||
}
|
||||
try {
|
||||
impl()->setQuad(quadEnable == 0 ? false : true);
|
||||
} catch(const RuntimeError &e) {
|
||||
throw RuntimeError("Could not set quad to " + std::to_string(quadEnable) + " due to fifo strucutre memory allocation");
|
||||
}
|
||||
}
|
||||
int retval = impl()->getQuad() ? 1 : 0;
|
||||
validate(quadEnable, retval, "set quad", DEC);
|
||||
@ -1296,8 +1323,10 @@ int ClientInterface::set_num_interfaces(Interface &socket) {
|
||||
throw RuntimeError("Number of interfaces not implemented for this detector");
|
||||
}
|
||||
FILE_LOG(logDEBUG1) << "Setting Number of UDP Interfaces:" << arg;
|
||||
if (impl()->setNumberofUDPInterfaces(arg) == FAIL) {
|
||||
throw RuntimeError("Failed to set number of interfaces");
|
||||
try {
|
||||
impl()->setNumberofUDPInterfaces(arg);
|
||||
} catch(const RuntimeError &e) {
|
||||
throw RuntimeError("Failed to set number of interfaces to " + std::to_string(arg));
|
||||
}
|
||||
return socket.Send(OK);
|
||||
}
|
||||
@ -1306,7 +1335,11 @@ int ClientInterface::set_adc_mask_10g(Interface &socket) {
|
||||
auto arg = socket.Receive<uint32_t>();
|
||||
VerifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting 10Gb ADC enable mask: " << arg;
|
||||
impl()->setTenGigaADCEnableMask(arg);
|
||||
try {
|
||||
impl()->setTenGigaADCEnableMask(arg);
|
||||
} catch(const RuntimeError &e) {
|
||||
throw RuntimeError("Could not set 10Gb adc enable mask due to fifo memory allcoation");
|
||||
}
|
||||
auto retval = impl()->getTenGigaADCEnableMask();
|
||||
if (retval != arg) {
|
||||
std::ostringstream os;
|
||||
|
@ -62,11 +62,8 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo* f,
|
||||
rawDataModifyReadyCallBack(nullptr),
|
||||
pRawDataReady(nullptr)
|
||||
{
|
||||
if(ThreadObject::CreateThread() == FAIL)
|
||||
throw sls::RuntimeError("Could not create processing thread");
|
||||
|
||||
ThreadObject::CreateThread();
|
||||
FILE_LOG(logDEBUG) << "DataProcessor " << ind << " created";
|
||||
|
||||
memset((void*)&timerBegin, 0, sizeof(timespec));
|
||||
}
|
||||
|
||||
@ -158,13 +155,17 @@ void DataProcessor::SetGeneralData(GeneralData* g) {
|
||||
}
|
||||
|
||||
|
||||
int DataProcessor::SetThreadPriority(int priority) {
|
||||
void DataProcessor::SetThreadPriority(int priority) {
|
||||
struct sched_param param;
|
||||
param.sched_priority = priority;
|
||||
if (pthread_setschedparam(thread, SCHED_FIFO, ¶m) == EPERM)
|
||||
return FAIL;
|
||||
FILE_LOG(logINFO) << "Processor Thread Priority set to " << priority;
|
||||
return OK;
|
||||
if (pthread_setschedparam(thread, SCHED_FIFO, ¶m) == EPERM) {
|
||||
if (!index) {
|
||||
FILE_LOG(logWARNING) << "Could not prioritize dataprocessing thread. "
|
||||
"(No Root Privileges?)";
|
||||
}
|
||||
} else {
|
||||
FILE_LOG(logINFO) << "Priorities set - DataProcessor: " << priority;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -220,16 +221,14 @@ void DataProcessor::SetupFileWriter(bool fwe, int* nd, uint32_t* maxf,
|
||||
}
|
||||
|
||||
// only the first file
|
||||
int DataProcessor::CreateNewFile(masterAttributes& attr) {
|
||||
if (file == nullptr)
|
||||
return FAIL;
|
||||
void DataProcessor::CreateNewFile(masterAttributes& attr) {
|
||||
if (file == nullptr) {
|
||||
throw sls::RuntimeError("file object not contstructed");
|
||||
}
|
||||
file->CloseAllFiles();
|
||||
file->resetSubFileIndex();
|
||||
if (file->CreateMasterFile(*masterFileWriteEnable, attr) == FAIL)
|
||||
return FAIL;
|
||||
if (file->CreateFile() == FAIL)
|
||||
return FAIL;
|
||||
return OK;
|
||||
file->CreateMasterFile(*masterFileWriteEnable, attr);
|
||||
file->CreateFile();
|
||||
}
|
||||
|
||||
|
||||
@ -240,7 +239,11 @@ void DataProcessor::CloseFiles() {
|
||||
|
||||
void DataProcessor::EndofAcquisition(bool anyPacketsCaught, uint64_t numf) {
|
||||
if ((file != nullptr) && file->GetFileType() == HDF5) {
|
||||
file->EndofAcquisition(anyPacketsCaught, numf);
|
||||
try {
|
||||
file->EndofAcquisition(anyPacketsCaught, numf);
|
||||
} catch (const sls::RuntimeError &e) {
|
||||
;// ignore for now //TODO: send error to client via stop receiver
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -352,10 +355,15 @@ void DataProcessor::ProcessAnImage(char* buf) {
|
||||
|
||||
|
||||
// write to file
|
||||
if (file != nullptr)
|
||||
file->WriteToFile(buf + FIFO_HEADER_NUMBYTES,
|
||||
sizeof(sls_receiver_header) + (uint32_t)(*((uint32_t*)buf)), //+ size of data (resizable from previous call back
|
||||
fnum-firstIndex, nump);
|
||||
if (file != nullptr) {
|
||||
try {
|
||||
file->WriteToFile(buf + FIFO_HEADER_NUMBYTES,
|
||||
sizeof(sls_receiver_header) + (uint32_t)(*((uint32_t*)buf)), //+ size of data (resizable from previous call back
|
||||
fnum-firstIndex, nump);
|
||||
} catch(const sls::RuntimeError &e) {
|
||||
; //ignore write exception for now (TODO: send error message via stopReceiver tcp)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -38,12 +38,8 @@ DataStreamer::DataStreamer(int ind, Fifo* f, uint32_t* dr, ROI* r,
|
||||
numDet[0] = nd[0];
|
||||
numDet[1] = nd[1];
|
||||
|
||||
if(ThreadObject::CreateThread() == FAIL)
|
||||
throw sls::RuntimeError("Could not create streaming thread");
|
||||
|
||||
ThreadObject::CreateThread();
|
||||
FILE_LOG(logDEBUG) << "DataStreamer " << ind << " created";
|
||||
|
||||
// memset(fileNametoStream, 0, MAX_STR_LENGTH);
|
||||
}
|
||||
|
||||
|
||||
@ -82,7 +78,6 @@ void DataStreamer::ResetParametersforNewAcquisition(const std::string& fname){
|
||||
startedFlag = false;
|
||||
firstIndex = 0;
|
||||
|
||||
// strcpy(fileNametoStream, fname);
|
||||
fileNametoStream = fname;
|
||||
if (completeBuffer) {
|
||||
delete[] completeBuffer;
|
||||
@ -109,13 +104,17 @@ void DataStreamer::SetGeneralData(GeneralData* g) {
|
||||
generalData->Print();
|
||||
}
|
||||
|
||||
int DataStreamer::SetThreadPriority(int priority) {
|
||||
void DataStreamer::SetThreadPriority(int priority) {
|
||||
struct sched_param param;
|
||||
param.sched_priority = priority;
|
||||
if (pthread_setschedparam(thread, SCHED_FIFO, ¶m) == EPERM)
|
||||
return FAIL;
|
||||
FILE_LOG(logINFO) << "Streamer Thread Priority set to " << priority;
|
||||
return OK;
|
||||
if (pthread_setschedparam(thread, SCHED_FIFO, ¶m) == EPERM) {
|
||||
if (!index) {
|
||||
FILE_LOG(logWARNING) << "Could not prioritize datastreaming thread. "
|
||||
"(No Root Privileges?)";
|
||||
}
|
||||
} else {
|
||||
FILE_LOG(logINFO) << "Priorities set - DataStreamer: " << priority;
|
||||
}
|
||||
}
|
||||
|
||||
void DataStreamer::SetNumberofDetectors(int* nd) {
|
||||
@ -258,14 +257,12 @@ int DataStreamer::SendHeader(sls_receiver_header* rheader, uint32_t size, uint32
|
||||
|
||||
|
||||
|
||||
int DataStreamer::RestreamStop() {
|
||||
void DataStreamer::RestreamStop() {
|
||||
//send dummy header
|
||||
int ret = zmqSocket->SendHeaderData(index, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
if (!ret) {
|
||||
FILE_LOG(logERROR) << "Could not Restream Dummy Header via ZMQ for port " << zmqSocket->GetPortNumber();
|
||||
return FAIL;
|
||||
throw sls::RuntimeError("Could not restream Dummy Header via ZMQ for port " + std::to_string(zmqSocket->GetPortNumber()));
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,8 +23,7 @@ Fifo::Fifo(int ind, uint32_t fifoItemSize, uint32_t depth):
|
||||
status_fifoBound(0),
|
||||
status_fifoFree(depth){
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
if(CreateFifos(fifoItemSize) == FAIL)
|
||||
throw sls::RuntimeError("Could not create FIFO");
|
||||
CreateFifos(fifoItemSize);
|
||||
}
|
||||
|
||||
|
||||
@ -35,7 +34,7 @@ Fifo::~Fifo() {
|
||||
|
||||
|
||||
|
||||
int Fifo::CreateFifos(uint32_t fifoItemSize) {
|
||||
void Fifo::CreateFifos(uint32_t fifoItemSize) {
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
|
||||
//destroy if not already
|
||||
@ -49,8 +48,7 @@ int Fifo::CreateFifos(uint32_t fifoItemSize) {
|
||||
size_t mem_len = fifoItemSize * fifoDepth * sizeof(char);
|
||||
memory = (char*) malloc (mem_len);
|
||||
if (memory == nullptr){
|
||||
FILE_LOG(logERROR) << "Could not allocate memory for fifos";
|
||||
return FAIL;
|
||||
throw sls::RuntimeError("Could not allocate memory for fifos");
|
||||
}
|
||||
memset(memory, 0, mem_len);
|
||||
FILE_LOG(logDEBUG) << "Memory Allocated " << index << ": " << mem_len << " bytes";
|
||||
@ -64,7 +62,6 @@ int Fifo::CreateFifos(uint32_t fifoItemSize) {
|
||||
}
|
||||
}
|
||||
FILE_LOG(logINFO) << "Fifo " << index << " reconstructed Depth (rx_fifodepth): " << fifoFree->getDataValue();
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -128,7 +128,7 @@ void HDF5File::UpdateDataType() {
|
||||
}
|
||||
|
||||
|
||||
int HDF5File::CreateFile() {
|
||||
void HDF5File::CreateFile() {
|
||||
numFilesinAcquisition++;
|
||||
numFramesInFile = 0;
|
||||
numActualPacketsInFile = 0;
|
||||
@ -143,21 +143,22 @@ int HDF5File::CreateFile() {
|
||||
(((extNumImages - subFileIndex) > (*maxFramesPerFile)) ? // save up to maximum at a time
|
||||
(*maxFramesPerFile) : (extNumImages-subFileIndex)));
|
||||
pthread_mutex_lock(&Mutex);
|
||||
if (HDF5FileStatic::CreateDataFile(index, *overWriteEnable, currentFileName, (*numImages > 1),
|
||||
try{
|
||||
HDF5FileStatic::CreateDataFile(index, *overWriteEnable, currentFileName, (*numImages > 1),
|
||||
subFileIndex, framestosave, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
|
||||
datatype, filefd, dataspace, dataset,
|
||||
HDF5_WRITER_VERSION, MAX_CHUNKED_IMAGES,
|
||||
dataspace_para, dataset_para,
|
||||
parameterNames, parameterDataTypes) == FAIL) {
|
||||
parameterNames, parameterDataTypes);
|
||||
} catch(const RuntimeError &e) {
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
return FAIL;
|
||||
throw;
|
||||
}
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
|
||||
if(!(*silentMode)) {
|
||||
FILE_LOG(logINFO) << *udpPortNumber << ": HDF5 File created: " << currentFileName;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
@ -195,7 +196,7 @@ void HDF5File::CloseAllFiles() {
|
||||
}
|
||||
|
||||
|
||||
int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) {
|
||||
void HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) {
|
||||
|
||||
// check if maxframesperfile = 0 for infinite
|
||||
if ((*maxFramesPerFile) && (numFramesInFile >= (*maxFramesPerFile))) {
|
||||
@ -207,40 +208,38 @@ int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t
|
||||
numActualPacketsInFile += nump;
|
||||
pthread_mutex_lock(&Mutex);
|
||||
|
||||
try {
|
||||
// extend dataset (when receiver start followed by many status starts (jungfrau)))
|
||||
if (fnum >= extNumImages) {
|
||||
if (HDF5FileStatic::ExtendDataset(index, dataspace, dataset,
|
||||
dataspace_para, dataset_para, *numImages) == OK) {
|
||||
if (!(*silentMode)) {
|
||||
FILE_LOG(logINFO) << index << " Extending HDF5 dataset by " <<
|
||||
extNumImages << ", Total x Dimension: " << (extNumImages + *numImages);
|
||||
}
|
||||
extNumImages += *numImages;
|
||||
HDF5FileStatic::ExtendDataset(index, dataspace, dataset,
|
||||
dataspace_para, dataset_para, *numImages);
|
||||
if (!(*silentMode)) {
|
||||
FILE_LOG(logINFO) << index << " Extending HDF5 dataset by " <<
|
||||
extNumImages << ", Total x Dimension: " << (extNumImages + *numImages);
|
||||
}
|
||||
extNumImages += *numImages;
|
||||
}
|
||||
|
||||
if (HDF5FileStatic::WriteDataFile(index, buffer + sizeof(sls_receiver_header),
|
||||
HDF5FileStatic::WriteDataFile(index, buffer + sizeof(sls_receiver_header),
|
||||
// infinite then no need for %maxframesperfile
|
||||
((*maxFramesPerFile == 0) ? fnum : fnum%(*maxFramesPerFile)),
|
||||
nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
|
||||
dataspace, dataset, datatype) == OK) {
|
||||
dataspace, dataset, datatype);
|
||||
|
||||
if (HDF5FileStatic::WriteParameterDatasets(index, dataspace_para,
|
||||
HDF5FileStatic::WriteParameterDatasets(index, dataspace_para,
|
||||
// infinite then no need for %maxframesperfile
|
||||
((*maxFramesPerFile == 0) ? fnum : fnum%(*maxFramesPerFile)),
|
||||
dataset_para, (sls_receiver_header*) (buffer),
|
||||
parameterDataTypes) == OK) {
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
return OK;
|
||||
}
|
||||
parameterDataTypes);
|
||||
} catch (const RuntimeError &e) {
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
throw;
|
||||
}
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
FILE_LOG(logERROR) << index << "Write to file failed";
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
|
||||
int HDF5File::CreateMasterFile(bool mfwenable, masterAttributes& attr) {
|
||||
void HDF5File::CreateMasterFile(bool mfwenable, masterAttributes& attr) {
|
||||
|
||||
//beginning of every acquisition
|
||||
numFramesInFile = 0;
|
||||
@ -256,12 +255,14 @@ int HDF5File::CreateMasterFile(bool mfwenable, masterAttributes& attr) {
|
||||
}
|
||||
pthread_mutex_lock(&Mutex);
|
||||
attr.version = HDF5_WRITER_VERSION;
|
||||
int ret = HDF5FileStatic::CreateMasterDataFile(masterfd, masterFileName,
|
||||
try{
|
||||
HDF5FileStatic::CreateMasterDataFile(masterfd, masterFileName,
|
||||
*overWriteEnable, attr);
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
return ret;
|
||||
} catch (const RuntimeError &e) {
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
@ -286,15 +287,15 @@ void HDF5File::EndofAcquisition(bool anyPacketsCaught, uint64_t numf) {
|
||||
|
||||
|
||||
// called only by the one maser receiver
|
||||
int HDF5File::CreateVirtualFile(uint64_t numf) {
|
||||
void HDF5File::CreateVirtualFile(uint64_t numf) {
|
||||
pthread_mutex_lock(&Mutex);
|
||||
|
||||
std::string vname = HDF5FileStatic::CreateVirtualFileName(*filePath, *fileNamePrefix, *fileIndex);
|
||||
if(!(*silentMode)) {
|
||||
FILE_LOG(logINFO) << "Virtual File: " << vname;
|
||||
}
|
||||
|
||||
int ret = HDF5FileStatic::CreateVirtualDataFile(vname,
|
||||
try {
|
||||
HDF5FileStatic::CreateVirtualDataFile(vname,
|
||||
virtualfd, masterFileName,
|
||||
*filePath, *fileNamePrefix, *fileIndex, (*numImages > 1),
|
||||
*detIndex, *numUnitsPerDetector,
|
||||
@ -305,12 +306,15 @@ int HDF5File::CreateVirtualFile(uint64_t numf) {
|
||||
numDetY, numDetX, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
|
||||
HDF5_WRITER_VERSION,
|
||||
parameterNames, parameterDataTypes);
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
return ret;
|
||||
} catch (const RuntimeError &e) {
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
throw;
|
||||
}
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
}
|
||||
|
||||
// called only by the one maser receiver
|
||||
int HDF5File::LinkVirtualFileinMasterFile() {
|
||||
void HDF5File::LinkVirtualFileinMasterFile() {
|
||||
//dataset name
|
||||
std::ostringstream osfn;
|
||||
osfn << "/data";
|
||||
@ -318,8 +322,12 @@ int HDF5File::LinkVirtualFileinMasterFile() {
|
||||
std::string dsetname = osfn.str();
|
||||
|
||||
pthread_mutex_lock(&Mutex);
|
||||
int ret = HDF5FileStatic::LinkVirtualInMaster(masterFileName, currentFileName,
|
||||
try {
|
||||
HDF5FileStatic::LinkVirtualInMaster(masterFileName, currentFileName,
|
||||
dsetname, parameterNames);
|
||||
} catch (const RuntimeError &e) {
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
throw;
|
||||
}
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
return ret;
|
||||
}
|
||||
|
@ -18,9 +18,10 @@
|
||||
|
||||
/** cosntructor & destructor */
|
||||
|
||||
Implementation::Implementation() {
|
||||
Implementation::Implementation(const detectorType d) {
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
InitializeMembers();
|
||||
setDetectorType(d);
|
||||
}
|
||||
|
||||
Implementation::~Implementation() {
|
||||
@ -160,23 +161,12 @@ void Implementation::SetLocalNetworkParameters() {
|
||||
|
||||
void Implementation::SetThreadPriorities() {
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
|
||||
for (const auto &it : listener) {
|
||||
if (it->SetThreadPriority(LISTENER_PRIORITY) == FAIL) {
|
||||
FILE_LOG(logWARNING) << "Could not prioritize listener threads. "
|
||||
"(No Root Privileges?)";
|
||||
return;
|
||||
}
|
||||
it->SetThreadPriority(LISTENER_PRIORITY);
|
||||
}
|
||||
std::ostringstream osfn;
|
||||
osfn << "Priorities set - "
|
||||
"Listener:"
|
||||
<< LISTENER_PRIORITY;
|
||||
|
||||
FILE_LOG(logINFO) << osfn.str();
|
||||
}
|
||||
|
||||
int Implementation::SetupFifoStructure() {
|
||||
void Implementation::SetupFifoStructure() {
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
|
||||
fifo.clear();
|
||||
@ -189,11 +179,8 @@ int Implementation::SetupFifoStructure() {
|
||||
(generalData->imageSize) + (generalData->fifoBufferHeaderSize),
|
||||
fifoDepth));
|
||||
} catch (...) {
|
||||
FILE_LOG(logERROR)
|
||||
<< "Could not allocate memory for fifo structure of index "
|
||||
<< i;
|
||||
fifo.clear();
|
||||
return FAIL;
|
||||
throw sls::RuntimeError("Could not allocate memory for fifo structure " + std::to_string(i));
|
||||
}
|
||||
// set the listener & dataprocessor threads to point to the right fifo
|
||||
if (listener.size())
|
||||
@ -210,7 +197,6 @@ int Implementation::SetupFifoStructure() {
|
||||
fifoDepth)
|
||||
<< " bytes";
|
||||
FILE_LOG(logINFO) << numThreads << " Fifo structure(s) reconstructed";
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
@ -221,10 +207,8 @@ int Implementation::SetupFifoStructure() {
|
||||
* *
|
||||
* ************************************************/
|
||||
|
||||
int Implementation::setDetectorType(const detectorType d) {
|
||||
void Implementation::setDetectorType(const detectorType d) {
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
DeleteMembers();
|
||||
InitializeMembers();
|
||||
myDetectorType = d;
|
||||
switch (myDetectorType) {
|
||||
case GOTTHARD:
|
||||
@ -237,8 +221,7 @@ int Implementation::setDetectorType(const detectorType d) {
|
||||
<< " Receiver *****";
|
||||
break;
|
||||
default:
|
||||
FILE_LOG(logERROR) << "This is an unknown receiver type " << (int)d;
|
||||
return FAIL;
|
||||
throw sls::RuntimeError("This is an unknown receiver type " + std::to_string(static_cast<int>(d)));
|
||||
}
|
||||
|
||||
// set detector specific variables
|
||||
@ -270,10 +253,7 @@ int Implementation::setDetectorType(const detectorType d) {
|
||||
framesPerFile = generalData->maxFramesPerFile;
|
||||
|
||||
SetLocalNetworkParameters();
|
||||
if (SetupFifoStructure() == FAIL) {
|
||||
FILE_LOG(logERROR) << "Could not allocate memory for fifo structure";
|
||||
return FAIL;
|
||||
}
|
||||
SetupFifoStructure();
|
||||
|
||||
// create threads
|
||||
for (int i = 0; i < numThreads; ++i) {
|
||||
@ -293,12 +273,9 @@ int Implementation::setDetectorType(const detectorType d) {
|
||||
&silentMode, &quadEnable, &ctbDbitList, &ctbDbitOffset,
|
||||
&ctbAnalogDataBytes));
|
||||
} catch (...) {
|
||||
FILE_LOG(logERROR)
|
||||
<< "Could not create listener/dataprocessor threads (index:"
|
||||
<< i << ")";
|
||||
listener.clear();
|
||||
dataProcessor.clear();
|
||||
return FAIL;
|
||||
throw sls::RuntimeError("Could not create listener/dataprocessor threads (index:" + std::to_string(i) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
@ -311,7 +288,6 @@ int Implementation::setDetectorType(const detectorType d) {
|
||||
SetThreadPriorities();
|
||||
|
||||
FILE_LOG(logDEBUG) << " Detector type set to " << sls::ToString(d);
|
||||
return OK;
|
||||
}
|
||||
|
||||
int *Implementation::getMultiDetectorSize() const {
|
||||
@ -404,14 +380,12 @@ uint32_t Implementation::getFifoDepth() const {
|
||||
return fifoDepth;
|
||||
}
|
||||
|
||||
int Implementation::setFifoDepth(const uint32_t i) {
|
||||
void Implementation::setFifoDepth(const uint32_t i) {
|
||||
if (fifoDepth != i) {
|
||||
fifoDepth = i;
|
||||
if (SetupFifoStructure() == FAIL)
|
||||
throw sls::RuntimeError("Failed to setup fifo structure");
|
||||
SetupFifoStructure();
|
||||
}
|
||||
FILE_LOG(logINFO) << "Fifo Depth: " << i;
|
||||
return OK;
|
||||
}
|
||||
|
||||
slsDetectorDefs::frameDiscardPolicy
|
||||
@ -625,18 +599,14 @@ std::vector<uint64_t> Implementation::getNumMissingPackets() const {
|
||||
return mp;
|
||||
}
|
||||
|
||||
int Implementation::startReceiver(std::string& err) {
|
||||
void Implementation::startReceiver() {
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
FILE_LOG(logINFO) << "Starting Receiver";
|
||||
stoppedFlag = false;
|
||||
ResetParametersforNewAcquisition();
|
||||
|
||||
// listener
|
||||
if (CreateUDPSockets() == FAIL) {
|
||||
err.assign("Could not create UDP Socket(s).");
|
||||
FILE_LOG(logERROR) << err;
|
||||
return FAIL;
|
||||
}
|
||||
CreateUDPSockets();
|
||||
|
||||
// callbacks
|
||||
if (startAcquisitionCallBack) {
|
||||
@ -651,11 +621,7 @@ int Implementation::startReceiver(std::string& err) {
|
||||
|
||||
// processor->writer
|
||||
if (fileWriteEnable) {
|
||||
if (SetupWriter() == FAIL) {
|
||||
err.assign("Could not create file.\n");
|
||||
FILE_LOG(logERROR) << err;
|
||||
return FAIL;
|
||||
}
|
||||
SetupWriter();
|
||||
} else
|
||||
FILE_LOG(logINFO) << "File Write Disabled";
|
||||
|
||||
@ -669,7 +635,6 @@ int Implementation::startReceiver(std::string& err) {
|
||||
|
||||
FILE_LOG(logINFO) << "Receiver Started";
|
||||
FILE_LOG(logINFO) << "Status: " << sls::ToString(status);
|
||||
return OK;
|
||||
}
|
||||
|
||||
void Implementation::setStoppedFlag(bool stopped) {
|
||||
@ -817,14 +782,12 @@ void Implementation::closeFiles() {
|
||||
dataProcessor[0]->EndofAcquisition(anycaught, maxIndexCaught);
|
||||
}
|
||||
|
||||
int Implementation::restreamStop() {
|
||||
void Implementation::restreamStop() {
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
for (const auto &it : dataStreamer) {
|
||||
if (it->RestreamStop() == FAIL)
|
||||
throw sls::RuntimeError("Could not restream stop packet");
|
||||
it->RestreamStop();
|
||||
}
|
||||
FILE_LOG(logINFO) << "Restreaming Dummy Header via ZMQ successful";
|
||||
return OK;
|
||||
}
|
||||
|
||||
void Implementation::ResetParametersforNewAcquisition() {
|
||||
@ -844,29 +807,23 @@ void Implementation::ResetParametersforNewAcquisition() {
|
||||
}
|
||||
}
|
||||
|
||||
int Implementation::CreateUDPSockets() {
|
||||
void Implementation::CreateUDPSockets() {
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
bool error = false;
|
||||
|
||||
for (unsigned int i = 0; i < listener.size(); ++i) {
|
||||
if (listener[i]->CreateUDPSockets() == FAIL) {
|
||||
error = true;
|
||||
break;
|
||||
try{
|
||||
for (unsigned int i = 0; i < listener.size(); ++i) {
|
||||
listener[i]->CreateUDPSockets();
|
||||
}
|
||||
}
|
||||
|
||||
if (error) {
|
||||
} catch(const sls::RuntimeError &e) {
|
||||
shutDownUDPSockets();
|
||||
return FAIL;
|
||||
throw sls::RuntimeError("Could not create UDP Socket(s).");
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG) << "UDP socket(s) created successfully.";
|
||||
return OK;
|
||||
}
|
||||
|
||||
int Implementation::SetupWriter() {
|
||||
void Implementation::SetupWriter() {
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
bool error = false;
|
||||
masterAttributes attr;
|
||||
attr.detectorType = myDetectorType;
|
||||
attr.dynamicRange = dynamicRange;
|
||||
@ -892,18 +849,16 @@ int Implementation::SetupWriter() {
|
||||
for (auto &i : ctbDbitList) {
|
||||
attr.dbitlist |= (1 << i);
|
||||
}
|
||||
for (unsigned int i = 0; i < dataProcessor.size(); ++i)
|
||||
if (dataProcessor[i]->CreateNewFile(attr) == FAIL) {
|
||||
error = true;
|
||||
break;
|
||||
|
||||
try {
|
||||
for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
|
||||
dataProcessor[i]->CreateNewFile(attr);
|
||||
}
|
||||
if (error) {
|
||||
} catch(const sls::RuntimeError &e) {
|
||||
shutDownUDPSockets();
|
||||
closeFiles();
|
||||
return FAIL;
|
||||
throw sls::RuntimeError("Could not create file.");
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
void Implementation::StartRunning() {
|
||||
@ -935,7 +890,7 @@ int Implementation::getNumberofUDPInterfaces() const {
|
||||
return numUDPInterfaces;
|
||||
}
|
||||
|
||||
int Implementation::setNumberofUDPInterfaces(const int n) {
|
||||
void Implementation::setNumberofUDPInterfaces(const int n) {
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
|
||||
if (numUDPInterfaces != n) {
|
||||
@ -959,8 +914,7 @@ int Implementation::setNumberofUDPInterfaces(const int n) {
|
||||
udpSocketBufferSize = generalData->defaultUdpSocketBufferSize;
|
||||
|
||||
// fifo
|
||||
if (SetupFifoStructure() == FAIL)
|
||||
return FAIL;
|
||||
SetupFifoStructure();
|
||||
|
||||
// create threads
|
||||
for (int i = 0; i < numThreads; ++i) {
|
||||
@ -984,12 +938,9 @@ int Implementation::setNumberofUDPInterfaces(const int n) {
|
||||
&ctbDbitOffset, &ctbAnalogDataBytes));
|
||||
dataProcessor[i]->SetGeneralData(generalData);
|
||||
} catch (...) {
|
||||
FILE_LOG(logERROR)
|
||||
<< "Could not create listener/dataprocessor threads (index:"
|
||||
<< i << ")";
|
||||
listener.clear();
|
||||
dataProcessor.clear();
|
||||
return FAIL;
|
||||
throw sls::RuntimeError("Could not create listener/dataprocessor threads (index:" + std::to_string(i) + ")");
|
||||
}
|
||||
// streamer threads
|
||||
if (dataStreamEnable) {
|
||||
@ -1009,14 +960,11 @@ int Implementation::setNumberofUDPInterfaces(const int n) {
|
||||
&numThreads, streamingPort, streamingSrcIP);
|
||||
|
||||
} catch (...) {
|
||||
FILE_LOG(logERROR)
|
||||
<< "Could not create datastreamer threads (index:" << i
|
||||
<< ")";
|
||||
if (dataStreamEnable) {
|
||||
dataStreamer.clear();
|
||||
dataStreamEnable = false;
|
||||
}
|
||||
return FAIL;
|
||||
throw sls::RuntimeError("Could not create datastreamer threads (index:" + std::to_string(i) + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1041,13 +989,10 @@ int Implementation::setNumberofUDPInterfaces(const int n) {
|
||||
}
|
||||
|
||||
// test socket buffer size with current set up
|
||||
if (setUDPSocketBufferSize(0) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
setUDPSocketBufferSize(0);
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO) << "Number of Interfaces: " << numUDPInterfaces;
|
||||
return OK;
|
||||
}
|
||||
|
||||
std::string Implementation::getEthernetInterface() const {
|
||||
@ -1103,22 +1048,17 @@ int64_t Implementation::getUDPSocketBufferSize() const {
|
||||
return udpSocketBufferSize;
|
||||
}
|
||||
|
||||
int Implementation::setUDPSocketBufferSize(const int64_t s) {
|
||||
void Implementation::setUDPSocketBufferSize(const int64_t s) {
|
||||
int64_t size = (s == 0) ? udpSocketBufferSize : s;
|
||||
size_t listSize = listener.size();
|
||||
|
||||
if (myDetectorType == JUNGFRAU && (int)listSize != numUDPInterfaces) {
|
||||
FILE_LOG(logERROR) << "Number of Interfaces " << numUDPInterfaces
|
||||
<< " do not match listener size " << listSize;
|
||||
return FAIL;
|
||||
throw sls::RuntimeError("Number of Interfaces " + std::to_string(numUDPInterfaces) + " do not match listener size " + std::to_string(listSize));
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < listSize; ++i) {
|
||||
if (listener[i]->CreateDummySocketForUDPSocketBufferSize(size) == FAIL)
|
||||
return FAIL;
|
||||
listener[i]->CreateDummySocketForUDPSocketBufferSize(size);
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int64_t Implementation::getActualUDPSocketBufferSize() const {
|
||||
@ -1137,7 +1077,7 @@ bool Implementation::getDataStreamEnable() const {
|
||||
return dataStreamEnable;
|
||||
}
|
||||
|
||||
int Implementation::setDataStreamEnable(const bool enable) {
|
||||
void Implementation::setDataStreamEnable(const bool enable) {
|
||||
|
||||
if (dataStreamEnable != enable) {
|
||||
dataStreamEnable = enable;
|
||||
@ -1164,14 +1104,13 @@ int Implementation::setDataStreamEnable(const bool enable) {
|
||||
} catch (...) {
|
||||
dataStreamer.clear();
|
||||
dataStreamEnable = false;
|
||||
return FAIL;
|
||||
throw sls::RuntimeError("Could not set data stream enable.");
|
||||
}
|
||||
}
|
||||
SetThreadPriorities();
|
||||
}
|
||||
}
|
||||
FILE_LOG(logINFO) << "Data Send to Gui: " << dataStreamEnable;
|
||||
return OK;
|
||||
}
|
||||
|
||||
uint32_t Implementation::getStreamingFrequency() const {
|
||||
@ -1179,12 +1118,11 @@ uint32_t Implementation::getStreamingFrequency() const {
|
||||
return streamingFrequency;
|
||||
}
|
||||
|
||||
int Implementation::setStreamingFrequency(const uint32_t freq) {
|
||||
void Implementation::setStreamingFrequency(const uint32_t freq) {
|
||||
if (streamingFrequency != freq) {
|
||||
streamingFrequency = freq;
|
||||
}
|
||||
FILE_LOG(logINFO) << "Streaming Frequency: " << streamingFrequency;
|
||||
return OK;
|
||||
}
|
||||
|
||||
uint32_t Implementation::getStreamingTimer() const {
|
||||
@ -1307,7 +1245,7 @@ uint32_t Implementation::getNumberofAnalogSamples() const {
|
||||
return numberOfAnalogSamples;
|
||||
}
|
||||
|
||||
int Implementation::setNumberofAnalogSamples(const uint32_t i) {
|
||||
void Implementation::setNumberofAnalogSamples(const uint32_t i) {
|
||||
if (numberOfAnalogSamples != i) {
|
||||
numberOfAnalogSamples = i;
|
||||
|
||||
@ -1318,13 +1256,11 @@ int Implementation::setNumberofAnalogSamples(const uint32_t i) {
|
||||
|
||||
for (const auto &it : dataProcessor)
|
||||
it->SetPixelDimension();
|
||||
if (SetupFifoStructure() == FAIL)
|
||||
return FAIL;
|
||||
SetupFifoStructure();
|
||||
}
|
||||
FILE_LOG(logINFO) << "Number of Analog Samples: " << numberOfAnalogSamples;
|
||||
FILE_LOG(logINFO) << "Packets per Frame: "
|
||||
<< (generalData->packetsPerFrame);
|
||||
return OK;
|
||||
}
|
||||
|
||||
uint32_t Implementation::getNumberofDigitalSamples() const {
|
||||
@ -1332,7 +1268,7 @@ uint32_t Implementation::getNumberofDigitalSamples() const {
|
||||
return numberOfDigitalSamples;
|
||||
}
|
||||
|
||||
int Implementation::setNumberofDigitalSamples(const uint32_t i) {
|
||||
void Implementation::setNumberofDigitalSamples(const uint32_t i) {
|
||||
if (numberOfDigitalSamples != i) {
|
||||
numberOfDigitalSamples = i;
|
||||
|
||||
@ -1343,14 +1279,12 @@ int Implementation::setNumberofDigitalSamples(const uint32_t i) {
|
||||
|
||||
for (const auto &it : dataProcessor)
|
||||
it->SetPixelDimension();
|
||||
if (SetupFifoStructure() == FAIL)
|
||||
return FAIL;
|
||||
SetupFifoStructure();
|
||||
}
|
||||
FILE_LOG(logINFO) << "Number of Digital Samples: "
|
||||
<< numberOfDigitalSamples;
|
||||
FILE_LOG(logINFO) << "Packets per Frame: "
|
||||
<< (generalData->packetsPerFrame);
|
||||
return OK;
|
||||
}
|
||||
|
||||
uint32_t Implementation::getDynamicRange() const {
|
||||
@ -1358,7 +1292,7 @@ uint32_t Implementation::getDynamicRange() const {
|
||||
return dynamicRange;
|
||||
}
|
||||
|
||||
int Implementation::setDynamicRange(const uint32_t i) {
|
||||
void Implementation::setDynamicRange(const uint32_t i) {
|
||||
|
||||
if (dynamicRange != i) {
|
||||
dynamicRange = i;
|
||||
@ -1369,12 +1303,10 @@ int Implementation::setDynamicRange(const uint32_t i) {
|
||||
// to update npixelsx, npixelsy in file writer
|
||||
for (const auto &it : dataProcessor)
|
||||
it->SetPixelDimension();
|
||||
if (SetupFifoStructure() == FAIL)
|
||||
return FAIL;
|
||||
SetupFifoStructure();
|
||||
}
|
||||
}
|
||||
FILE_LOG(logINFO) << "Dynamic Range: " << dynamicRange;
|
||||
return OK;
|
||||
}
|
||||
|
||||
slsDetectorDefs::ROI Implementation::getROI() const {
|
||||
@ -1382,7 +1314,7 @@ slsDetectorDefs::ROI Implementation::getROI() const {
|
||||
return roi;
|
||||
}
|
||||
|
||||
int Implementation::setROI(slsDetectorDefs::ROI arg) {
|
||||
void Implementation::setROI(slsDetectorDefs::ROI arg) {
|
||||
if (roi.xmin != arg.xmin || roi.xmax != arg.xmax) {
|
||||
roi.xmin = arg.xmin;
|
||||
roi.xmax = arg.xmax;
|
||||
@ -1392,14 +1324,12 @@ int Implementation::setROI(slsDetectorDefs::ROI arg) {
|
||||
framesPerFile = generalData->maxFramesPerFile;
|
||||
for (const auto &it : dataProcessor)
|
||||
it->SetPixelDimension();
|
||||
if (SetupFifoStructure() == FAIL)
|
||||
return FAIL;
|
||||
SetupFifoStructure();
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO) << "ROI: [" << roi.xmin << ", " << roi.xmax << "]";;
|
||||
FILE_LOG(logINFO) << "Packets per Frame: "
|
||||
<< (generalData->packetsPerFrame);
|
||||
return OK;
|
||||
}
|
||||
|
||||
bool Implementation::getTenGigaEnable() const {
|
||||
@ -1407,7 +1337,7 @@ bool Implementation::getTenGigaEnable() const {
|
||||
return tengigaEnable;
|
||||
}
|
||||
|
||||
int Implementation::setTenGigaEnable(const bool b) {
|
||||
void Implementation::setTenGigaEnable(const bool b) {
|
||||
if (tengigaEnable != b) {
|
||||
tengigaEnable = b;
|
||||
// side effects
|
||||
@ -1427,13 +1357,11 @@ int Implementation::setTenGigaEnable(const bool b) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (SetupFifoStructure() == FAIL)
|
||||
return FAIL;
|
||||
SetupFifoStructure();
|
||||
}
|
||||
FILE_LOG(logINFO) << "Ten Giga: " << (tengigaEnable ? "enabled" : "disabled");
|
||||
FILE_LOG(logINFO) << "Packets per Frame: "
|
||||
<< (generalData->packetsPerFrame);
|
||||
return OK;
|
||||
}
|
||||
|
||||
int Implementation::getFlippedDataX() const {
|
||||
@ -1465,7 +1393,7 @@ bool Implementation::getGapPixelsEnable() const {
|
||||
return gapPixelsEnable;
|
||||
}
|
||||
|
||||
int Implementation::setGapPixelsEnable(const bool b) {
|
||||
void Implementation::setGapPixelsEnable(const bool b) {
|
||||
if (gapPixelsEnable != b) {
|
||||
gapPixelsEnable = b;
|
||||
|
||||
@ -1473,11 +1401,9 @@ int Implementation::setGapPixelsEnable(const bool b) {
|
||||
generalData->SetGapPixelsEnable(b, dynamicRange, quadEnable);
|
||||
for (const auto &it : dataProcessor)
|
||||
it->SetPixelDimension();
|
||||
if (SetupFifoStructure() == FAIL)
|
||||
return FAIL;
|
||||
SetupFifoStructure();
|
||||
}
|
||||
FILE_LOG(logINFO) << "Gap Pixels Enable: " << gapPixelsEnable;
|
||||
return OK;
|
||||
}
|
||||
|
||||
bool Implementation::getQuad() const {
|
||||
@ -1485,7 +1411,7 @@ bool Implementation::getQuad() const {
|
||||
return quadEnable;
|
||||
}
|
||||
|
||||
int Implementation::setQuad(const bool b) {
|
||||
void Implementation::setQuad(const bool b) {
|
||||
if (quadEnable != b) {
|
||||
quadEnable = b;
|
||||
|
||||
@ -1493,8 +1419,7 @@ int Implementation::setQuad(const bool b) {
|
||||
// to update npixelsx, npixelsy in file writer
|
||||
for (const auto &it : dataProcessor)
|
||||
it->SetPixelDimension();
|
||||
if (SetupFifoStructure() == FAIL)
|
||||
return FAIL;
|
||||
SetupFifoStructure();
|
||||
|
||||
if (!quadEnable) {
|
||||
for (const auto &it : dataStreamer) {
|
||||
@ -1513,7 +1438,6 @@ int Implementation::setQuad(const bool b) {
|
||||
}
|
||||
}
|
||||
FILE_LOG(logINFO) << "Quad Enable: " << quadEnable;
|
||||
return OK;
|
||||
}
|
||||
|
||||
bool Implementation::getActivate() const {
|
||||
@ -1557,7 +1481,7 @@ Implementation::getReadoutMode() const {
|
||||
return readoutType;
|
||||
}
|
||||
|
||||
int Implementation::setReadoutMode(const readoutMode f) {
|
||||
void Implementation::setReadoutMode(const readoutMode f) {
|
||||
if (readoutType != f) {
|
||||
readoutType = f;
|
||||
|
||||
@ -1568,14 +1492,12 @@ int Implementation::setReadoutMode(const readoutMode f) {
|
||||
tengigaEnable, readoutType);
|
||||
for (const auto &it : dataProcessor)
|
||||
it->SetPixelDimension();
|
||||
if (SetupFifoStructure() == FAIL)
|
||||
return FAIL;
|
||||
SetupFifoStructure();
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO) << "Readout Mode: " << sls::ToString(f);
|
||||
FILE_LOG(logINFO) << "Packets per Frame: "
|
||||
<< (generalData->packetsPerFrame);
|
||||
return OK;
|
||||
}
|
||||
|
||||
uint32_t Implementation::getADCEnableMask() const {
|
||||
@ -1583,7 +1505,7 @@ uint32_t Implementation::getADCEnableMask() const {
|
||||
return adcEnableMaskOneGiga;
|
||||
}
|
||||
|
||||
int Implementation::setADCEnableMask(uint32_t mask) {
|
||||
void Implementation::setADCEnableMask(uint32_t mask) {
|
||||
if (adcEnableMaskOneGiga != mask) {
|
||||
adcEnableMaskOneGiga = mask;
|
||||
|
||||
@ -1594,15 +1516,13 @@ int Implementation::setADCEnableMask(uint32_t mask) {
|
||||
|
||||
for (const auto &it : dataProcessor)
|
||||
it->SetPixelDimension();
|
||||
if (SetupFifoStructure() == FAIL)
|
||||
return FAIL;
|
||||
SetupFifoStructure();
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO) << "ADC Enable Mask for 1Gb mode: 0x" << std::hex << adcEnableMaskOneGiga
|
||||
<< std::dec;
|
||||
FILE_LOG(logINFO) << "Packets per Frame: "
|
||||
<< (generalData->packetsPerFrame);
|
||||
return OK;
|
||||
}
|
||||
|
||||
uint32_t Implementation::getTenGigaADCEnableMask() const {
|
||||
@ -1610,7 +1530,7 @@ uint32_t Implementation::getTenGigaADCEnableMask() const {
|
||||
return adcEnableMaskTenGiga;
|
||||
}
|
||||
|
||||
int Implementation::setTenGigaADCEnableMask(uint32_t mask) {
|
||||
void Implementation::setTenGigaADCEnableMask(uint32_t mask) {
|
||||
if (adcEnableMaskTenGiga != mask) {
|
||||
adcEnableMaskTenGiga = mask;
|
||||
|
||||
@ -1621,15 +1541,13 @@ int Implementation::setTenGigaADCEnableMask(uint32_t mask) {
|
||||
|
||||
for (const auto &it : dataProcessor)
|
||||
it->SetPixelDimension();
|
||||
if (SetupFifoStructure() == FAIL)
|
||||
return FAIL;
|
||||
SetupFifoStructure();
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO) << "ADC Enable Mask for 10Gb mode: 0x" << std::hex << adcEnableMaskTenGiga
|
||||
<< std::dec;
|
||||
FILE_LOG(logINFO) << "Packets per Frame: "
|
||||
<< (generalData->packetsPerFrame);
|
||||
return OK;
|
||||
}
|
||||
|
||||
std::vector<int> Implementation::getDbitList() const {
|
||||
|
@ -55,9 +55,7 @@ Listener::Listener(int ind, detectorType dtype, Fifo* f, std::atomic<runStatus>*
|
||||
numFramesStatistic(0),
|
||||
oddStartingPacket(true)
|
||||
{
|
||||
if(ThreadObject::CreateThread() == FAIL)
|
||||
throw sls::RuntimeError("Could not create listener thread");
|
||||
|
||||
ThreadObject::CreateThread();
|
||||
FILE_LOG(logDEBUG) << "Listener " << ind << " created";
|
||||
}
|
||||
|
||||
@ -155,19 +153,23 @@ void Listener::SetGeneralData(GeneralData* g) {
|
||||
}
|
||||
|
||||
|
||||
int Listener::SetThreadPriority(int priority) {
|
||||
void Listener::SetThreadPriority(int priority) {
|
||||
struct sched_param param;
|
||||
param.sched_priority = priority;
|
||||
if (pthread_setschedparam(thread, SCHED_FIFO, ¶m) == EPERM)
|
||||
return FAIL;
|
||||
FILE_LOG(logINFO) << "Listener Thread Priority set to " << priority;
|
||||
return OK;
|
||||
if (pthread_setschedparam(thread, SCHED_FIFO, ¶m) == EPERM) {
|
||||
if (!index) {
|
||||
FILE_LOG(logWARNING) << "Could not prioritize listener thread. "
|
||||
"(No Root Privileges?)";
|
||||
}
|
||||
} else {
|
||||
FILE_LOG(logINFO) << "Priorities set - Listener: " << priority;
|
||||
}
|
||||
}
|
||||
|
||||
int Listener::CreateUDPSockets() {
|
||||
void Listener::CreateUDPSockets() {
|
||||
|
||||
if (!(*activated)) {
|
||||
return OK;
|
||||
return;
|
||||
}
|
||||
|
||||
//if eth is mistaken with ip address
|
||||
@ -186,8 +188,7 @@ int Listener::CreateUDPSockets() {
|
||||
*udpSocketBufferSize);
|
||||
FILE_LOG(logINFO) << index << ": UDP port opened at port " << *udpPortNumber;
|
||||
} catch (...) {
|
||||
FILE_LOG(logERROR) << "Could not create UDP socket on port " << *udpPortNumber;
|
||||
return FAIL;
|
||||
throw sls::RuntimeError("Could not create UDP socket on port "+ std::to_string(*udpPortNumber));
|
||||
}
|
||||
|
||||
udpSocketAlive = true;
|
||||
@ -195,8 +196,6 @@ int Listener::CreateUDPSockets() {
|
||||
|
||||
// doubled due to kernel bookkeeping (could also be less due to permissions)
|
||||
*actualUDPSocketBufferSize = udpSocket->getActualUDPSocketBufferSize();
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
@ -216,12 +215,12 @@ void Listener::ShutDownUDPSocket() {
|
||||
}
|
||||
|
||||
|
||||
int Listener::CreateDummySocketForUDPSocketBufferSize(int64_t s) {
|
||||
void Listener::CreateDummySocketForUDPSocketBufferSize(int64_t s) {
|
||||
FILE_LOG(logINFO) << "Testing UDP Socket Buffer size " << s << " with test port " << *udpPortNumber;
|
||||
|
||||
if (!(*activated)) {
|
||||
*actualUDPSocketBufferSize = (s*2);
|
||||
return OK;
|
||||
return;
|
||||
}
|
||||
|
||||
int64_t temp = *udpSocketBufferSize;
|
||||
@ -247,12 +246,8 @@ int Listener::CreateDummySocketForUDPSocketBufferSize(int64_t s) {
|
||||
}
|
||||
|
||||
} catch (...) {
|
||||
FILE_LOG(logERROR) << "Could not create a test UDP socket on port " << *udpPortNumber;
|
||||
return FAIL;
|
||||
throw sls::RuntimeError("Could not create a test UDP socket on port " + std::to_string(*udpPortNumber));
|
||||
}
|
||||
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
void Listener::SetHardCodedPosition(uint16_t r, uint16_t c) {
|
||||
|
@ -48,22 +48,18 @@ void ThreadObject::DestroyThread() {
|
||||
}
|
||||
|
||||
|
||||
int ThreadObject::CreateThread() {
|
||||
if(alive){
|
||||
FILE_LOG(logERROR) << "Cannot create thread " << index << ". Already alive";
|
||||
return FAIL;
|
||||
void ThreadObject::CreateThread() {
|
||||
if (alive) {
|
||||
throw sls::RuntimeError("Cannot create " + GetType() + " thread " + std::to_string(index) + ". Already alive");
|
||||
}
|
||||
sem_init(&semaphore,1,0);
|
||||
killThread = false;
|
||||
|
||||
if(pthread_create(&thread, nullptr,StartThread, (void*) this)){
|
||||
FILE_LOG(logERROR) << "Could not create " << GetType() << " thread with index " << index;
|
||||
return FAIL;
|
||||
if (pthread_create(&thread, nullptr,StartThread, (void*) this)){
|
||||
throw sls::RuntimeError("Could not create " + GetType() + " thread with index " + std::to_string(index));
|
||||
}
|
||||
alive = true;
|
||||
FILE_LOG(logDEBUG) << GetType() << " thread " << index << " created successfully.";
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -4,9 +4,9 @@
|
||||
#define APIRECEIVER 0x190722
|
||||
#define APIGUI 0x190723
|
||||
#define APIMOENCH 0x190820
|
||||
#define APIEIGER 0x191111
|
||||
#define APIGOTTHARD2 0x191127
|
||||
#define APIMYTHEN3 0x191127
|
||||
#define APICTB 0x191127
|
||||
#define APIGOTTHARD 0x191127
|
||||
#define APIJUNGFRAU 0x191127
|
||||
#define APIEIGER 0x191129
|
||||
|
Loading…
x
Reference in New Issue
Block a user