rxr: removed char array memebers in rxrimplementation

This commit is contained in:
maliakal_d 2019-11-18 14:29:01 +01:00
parent 32cf46a8a3
commit f2c0ff7f98
23 changed files with 99 additions and 116 deletions

View File

@ -35,7 +35,7 @@ class BinaryFile : private virtual slsDetectorDefs, public File, public BinaryFi
* @param smode pointer to silent mode * @param smode pointer to silent mode
*/ */
BinaryFile(int ind, uint32_t* maxf, BinaryFile(int ind, uint32_t* maxf,
int* nd, char* fname, char* fpath, uint64_t* findex, bool* owenable, int* nd, std::string* fname, std::string* fpath, uint64_t* findex, bool* owenable,
int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno,
bool* smode); bool* smode);

View File

@ -40,7 +40,7 @@ class BinaryFileStatic {
* @param unitindex unit index * @param unitindex unit index
* @returns complete file name created * @returns complete file name created
*/ */
static std::string CreateFileName(char *fpath, char *fprefix, static std::string CreateFileName(std::string fpath, std::string fprefix,
uint64_t findex, uint64_t subfindex, uint64_t findex, uint64_t subfindex,
int dindex, int numunits = 1, int dindex, int numunits = 1,
int unitindex = 0) { int unitindex = 0) {
@ -58,7 +58,7 @@ class BinaryFileStatic {
* @param findex file index * @param findex file index
* @returns master file name * @returns master file name
*/ */
static std::string CreateMasterFileName(char *fpath, char *fnameprefix, static std::string CreateMasterFileName(std::string fpath, std::string fnameprefix,
uint64_t findex) { uint64_t findex) {
std::ostringstream os; std::ostringstream os;
os << fpath << "/" << fnameprefix << "_master" os << fpath << "/" << fnameprefix << "_master"

View File

@ -147,8 +147,8 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
* @param portno pointer to udp port number * @param portno pointer to udp port number
* @param g address of GeneralData (Detector Data) pointer * @param g address of GeneralData (Detector Data) pointer
*/ */
void SetupFileWriter(bool fwe, int* nd, uint32_t* maxf, char* fname, void SetupFileWriter(bool fwe, int* nd, uint32_t* maxf, std::string* fname,
char* fpath, uint64_t* findex, std::string* fpath, uint64_t* findex,
bool* owenable, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, bool* owenable, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr,
uint32_t* portno, GeneralData* g = nullptr); uint32_t* portno, GeneralData* g = nullptr);

View File

@ -35,7 +35,7 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
* @param qe pointer to quad Enable * @param qe pointer to quad Enable
*/ */
DataStreamer(int ind, Fifo* f, uint32_t* dr, ROI* r, DataStreamer(int ind, Fifo* f, uint32_t* dr, ROI* r,
uint64_t* fi, int fd, char* ajh, int* nd, bool* gpEnable, bool* qe); uint64_t* fi, int fd, std::string* ajh, int* nd, bool* gpEnable, bool* qe);
/** /**
* Destructor * Destructor
@ -197,7 +197,7 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
int flippedDataX; int flippedDataX;
/** additional json header */ /** additional json header */
char* additionJsonHeader; std::string* additionJsonHeader;
/** Aquisition Started flag */ /** Aquisition Started flag */
bool startedFlag; bool startedFlag;

View File

@ -36,7 +36,7 @@ class File : private virtual slsDetectorDefs {
* @param smode pointer to silent mode * @param smode pointer to silent mode
*/ */
File(int ind, uint32_t* maxf, File(int ind, uint32_t* maxf,
int* nd, char* fname, char* fpath, uint64_t* findex, bool* owenable, int* nd, std::string* fname, std::string* fpath, uint64_t* findex, bool* owenable,
int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno,
bool* smode); bool* smode);
@ -78,7 +78,7 @@ class File : private virtual slsDetectorDefs {
* @param dr pointer to dynamic range * @param dr pointer to dynamic range
* @param portno pointer to dynamic range * @param portno pointer to dynamic range
*/ */
void GetMemberPointerValues(int* nd, uint32_t*& maxf, char*& fname, char*& fpath, void GetMemberPointerValues(int* nd, uint32_t*& maxf, std::string*& fname, std::string*& fpath,
uint64_t*& findex, bool*& owenable, uint64_t*& findex, bool*& owenable,
int*& dindex, int*& nunits, uint64_t*& nf, uint32_t*& dr, uint32_t*& portno); int*& dindex, int*& nunits, uint64_t*& nf, uint32_t*& dr, uint32_t*& portno);
@ -161,10 +161,10 @@ class File : private virtual slsDetectorDefs {
int numDetY; int numDetY;
/** File Name Prefix */ /** File Name Prefix */
char* fileNamePrefix; std::string* fileNamePrefix;
/** File Path */ /** File Path */
char* filePath; std::string* filePath;
/** File Index */ /** File Index */
uint64_t* fileIndex; uint64_t* fileIndex;

View File

@ -42,7 +42,7 @@ class HDF5File : private virtual slsDetectorDefs, public File, public HDF5FileSt
* @param smode pointer to silent mode * @param smode pointer to silent mode
*/ */
HDF5File(int ind, uint32_t* maxf, HDF5File(int ind, uint32_t* maxf,
int* nd, char* fname, char* fpath, uint64_t* findex, bool* owenable, int* nd, std::string* fname, std::string* fpath, uint64_t* findex, bool* owenable,
int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno,
uint32_t nx, uint32_t ny, uint32_t nx, uint32_t ny,
bool* smode); bool* smode);

View File

@ -46,7 +46,7 @@ public:
* @param unitindex unit index * @param unitindex unit index
* @returns complete file name created * @returns complete file name created
*/ */
static std::string CreateFileName(char *fpath, char *fprefix, static std::string CreateFileName(std::string fpath, std::string fprefix,
uint64_t findex, uint64_t subfindex, uint64_t findex, uint64_t subfindex,
int dindex, int numunits = 1, int dindex, int numunits = 1,
int unitindex = 0) { int unitindex = 0) {
@ -64,7 +64,7 @@ public:
* @param findex file index * @param findex file index
* @returns master file name * @returns master file name
*/ */
static std::string CreateMasterFileName(char* fpath, char* fnameprefix, uint64_t findex) static std::string CreateMasterFileName(std::string fpath, std::string fnameprefix, uint64_t findex)
{ {
std::ostringstream os; std::ostringstream os;
os << fpath << "/" << fnameprefix << "_master" os << fpath << "/" << fnameprefix << "_master"
@ -80,7 +80,7 @@ public:
* @param findex file index * @param findex file index
* @returns virtual file name * @returns virtual file name
*/ */
static std::string CreateVirtualFileName(char* fpath, char* fnameprefix, uint64_t findex) static std::string CreateVirtualFileName(std::string fpath, std::string fnameprefix, uint64_t findex)
{ {
std::ostringstream osfn; std::ostringstream osfn;
osfn << fpath << "/" << fnameprefix; osfn << fpath << "/" << fnameprefix;
@ -584,7 +584,7 @@ public:
static int CreateVirtualDataFile( static int CreateVirtualDataFile(
std::string virtualFileName, std::string virtualFileName,
hid_t& fd, std::string masterFileName, hid_t& fd, std::string masterFileName,
char* fpath, char* fnameprefix, uint64_t findex, bool frindexenable, std::string fpath, std::string fnameprefix, uint64_t findex, bool frindexenable,
int dindex, int numunits, int dindex, int numunits,
uint32_t maxFramesPerFile, uint64_t numf, uint32_t maxFramesPerFile, uint64_t numf,
std::string srcDataseName, DataType dataType, std::string srcDataseName, DataType dataType,

View File

@ -65,7 +65,7 @@ class slsReceiver : private virtual slsDetectorDefs {
* we write depending on file write enable * we write depending on file write enable
* users get data to write depending on call backs registered * users get data to write depending on call backs registered
*/ */
void registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg); void registerCallBackStartAcquisition(int (*func)(std::string, std::string, uint64_t, uint32_t, void*),void *arg);
/** /**
* Call back for acquisition finished * Call back for acquisition finished

View File

@ -60,7 +60,7 @@ class slsReceiverImplementation : private virtual slsDetectorDefs {
/* /*
* Get detector hostname * Get detector hostname
* @return hostname (max of 1000 characters) * @return hostname
*/ */
std::string getDetectorHostname() const; std::string getDetectorHostname() const;
@ -376,7 +376,7 @@ class slsReceiverImplementation : private virtual slsDetectorDefs {
* Sets detector hostname * Sets detector hostname
* @param c detector hostname * @param c detector hostname
*/ */
void setDetectorHostname(const char *c); void setDetectorHostname(const std::string& c);
/* /*
* Set multi detector size * Set multi detector size
@ -428,17 +428,17 @@ class slsReceiverImplementation : private virtual slsDetectorDefs {
* Set File Name Prefix (without frame index, file index and extension * Set File Name Prefix (without frame index, file index and extension
* (_d0_f000000000000_8.raw)) Does not check for file existence since it is * (_d0_f000000000000_8.raw)) Does not check for file existence since it is
* created only at startReceiver * created only at startReceiver
* @param c file name (max of 1000 characters) * @param c file name
*/ */
void setFileName(const char c[]); void setFileName(const std::string& c);
/** /**
* Set File Path * Set File Path
* Checks for file directory existence before setting file path, * Checks for file directory existence before setting file path,
* If it exists, it sets it * If it exists, it sets it
* @param c file path (max of 1000 characters) * @param c file path
*/ */
void setFilePath(const char c[]); void setFilePath(const std::string& c);
/** /**
* Set File Index of acquisition * Set File Index of acquisition
@ -570,7 +570,7 @@ class slsReceiverImplementation : private virtual slsDetectorDefs {
/** /**
* Set additional json header * Set additional json header
*/ */
void setAdditionalJsonHeader(const char *c); void setAdditionalJsonHeader(const std::string& c);
/** /**
* Set Acquisition Period * Set Acquisition Period
@ -708,7 +708,7 @@ class slsReceiverImplementation : private virtual slsDetectorDefs {
* @param c error message if FAIL * @param c error message if FAIL
* @return OK or FAIL * @return OK or FAIL
*/ */
int startReceiver(char *c = NULL); int startReceiver(std::string& err);
/** /**
* Stop Listening for Packets * Stop Listening for Packets
@ -760,7 +760,7 @@ class slsReceiverImplementation : private virtual slsDetectorDefs {
* we write depending on file write enable * we write depending on file write enable
* users get data to write depending on call backs registered * users get data to write depending on call backs registered
*/ */
void registerCallBackStartAcquisition(int (*func)(char *, char *, uint64_t, void registerCallBackStartAcquisition(int (*func)(std::string, std::string, uint64_t,
uint32_t, void *), uint32_t, void *),
void *arg); void *arg);
@ -860,7 +860,7 @@ class slsReceiverImplementation : private virtual slsDetectorDefs {
/*Detector Readout ID*/ /*Detector Readout ID*/
int detID; int detID;
/** detector hostname */ /** detector hostname */
char detHostname[MAX_STR_LENGTH]; std::string detHostname;
/** Acquisition Period */ /** Acquisition Period */
uint64_t acquisitionPeriod; uint64_t acquisitionPeriod;
/** Acquisition Time */ /** Acquisition Time */
@ -932,10 +932,10 @@ class slsReceiverImplementation : private virtual slsDetectorDefs {
/** File format */ /** File format */
fileFormat fileFormatType; fileFormat fileFormatType;
/** File Name without frame index, file index and extension /** File Name without frame index, file index and extension
* (_d0_f000000000000_8.raw)*/ * (_d0_f0_8.raw)*/
char fileName[MAX_STR_LENGTH]; std::string fileName;
/** File Path */ /** File Path */
char filePath[MAX_STR_LENGTH]; std::string filePath;
/** File Index */ /** File Index */
uint64_t fileIndex; uint64_t fileIndex;
/** Frames per file (0 means infinite) */ /** Frames per file (0 means infinite) */
@ -963,7 +963,7 @@ class slsReceiverImplementation : private virtual slsDetectorDefs {
/** streaming port */ /** streaming port */
sls::IpAddr streamingSrcIP; sls::IpAddr streamingSrcIP;
/** additional json header */ /** additional json header */
char additionalJsonHeader[MAX_STR_LENGTH]; std::string additionalJsonHeader;
//** class objects *** //** class objects ***
/** General Data Properties */ /** General Data Properties */
@ -990,7 +990,7 @@ class slsReceiverImplementation : private virtual slsDetectorDefs {
* we write depending on file write enable * we write depending on file write enable
* users get data to write depending on call backs registered * users get data to write depending on call backs registered
*/ */
int (*startAcquisitionCallBack)(char *, char *, uint64_t, uint32_t, void *); int (*startAcquisitionCallBack)(std::string, std::string, uint64_t, uint32_t, void *);
void *pStartAcquisition; void *pStartAcquisition;
/** /**
* Call back for acquisition finished * Call back for acquisition finished

View File

@ -60,7 +60,7 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
* we write depending on file write enable * we write depending on file write enable
* users get data to write depending on call backs registered * users get data to write depending on call backs registered
*/ */
void registerCallBackStartAcquisition(int (*func)(char *, char *, uint64_t, void registerCallBackStartAcquisition(int (*func)(std::string, std::string, uint64_t,
uint32_t, void *), uint32_t, void *),
void *arg); void *arg);
@ -338,9 +338,6 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
int (slsReceiverTCPIPInterface::*flist[NUM_REC_FUNCTIONS])( int (slsReceiverTCPIPInterface::*flist[NUM_REC_FUNCTIONS])(
sls::ServerInterface2 &socket); sls::ServerInterface2 &socket);
/** Message */
char mess[MAX_STR_LENGTH]{};
/** success/failure */ /** success/failure */
int ret{OK}; int ret{OK};
@ -375,7 +372,7 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
* we write depending on file write enable * we write depending on file write enable
* users get data to write depending on call backs registered * users get data to write depending on call backs registered
*/ */
int (*startAcquisitionCallBack)(char *, char *, uint64_t, uint32_t, int (*startAcquisitionCallBack)(std::string, std::string, uint64_t, uint32_t,
void *) = nullptr; void *) = nullptr;
void *pStartAcquisition{nullptr}; void *pStartAcquisition{nullptr};

View File

@ -55,7 +55,7 @@ public:
\param arg argument \param arg argument
\return value is insignificant at the moment, we write depending on file write enable, users get data to write depending on call backs registered \return value is insignificant at the moment, we write depending on file write enable, users get data to write depending on call backs registered
*/ */
void registerCallBackStartAcquisition(int (*func)(char* filepath, char* filename, uint64_t fileindex, uint32_t datasize, void*),void *arg); void registerCallBackStartAcquisition(int (*func)(std::string filepath, std::string filename, uint64_t fileindex, uint32_t datasize, void*),void *arg);
/** /**

View File

@ -14,7 +14,7 @@
FILE* BinaryFile::masterfd = nullptr; FILE* BinaryFile::masterfd = nullptr;
BinaryFile::BinaryFile(int ind, uint32_t* maxf, BinaryFile::BinaryFile(int ind, uint32_t* maxf,
int* nd, char* fname, char* fpath, uint64_t* findex, bool* owenable, int* nd, std::string* fname, std::string* fpath, uint64_t* findex, bool* owenable,
int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno,
bool* smode): bool* smode):
File(ind, maxf, nd, fname, fpath, findex, owenable, dindex, nunits, nf, dr, portno, smode), File(ind, maxf, nd, fname, fpath, findex, owenable, dindex, nunits, nf, dr, portno, smode),
@ -46,7 +46,7 @@ int BinaryFile::CreateFile() {
numFramesInFile = 0; numFramesInFile = 0;
numActualPacketsInFile = 0; numActualPacketsInFile = 0;
currentFileName = BinaryFileStatic::CreateFileName(filePath, fileNamePrefix, *fileIndex, currentFileName = BinaryFileStatic::CreateFileName(*filePath, *fileNamePrefix, *fileIndex,
subFileIndex, *detIndex, *numUnitsPerDetector, index); subFileIndex, *detIndex, *numUnitsPerDetector, index);
if (BinaryFileStatic::CreateDataFile(filefd, *overWriteEnable, currentFileName, FILE_BUFFER_SIZE) == FAIL) if (BinaryFileStatic::CreateDataFile(filefd, *overWriteEnable, currentFileName, FILE_BUFFER_SIZE) == FAIL)
@ -120,8 +120,8 @@ int BinaryFile::CreateMasterFile(bool mfwenable, masterAttributes& attr) {
numActualPacketsInFile = 0; numActualPacketsInFile = 0;
if (mfwenable && master && (*detIndex==0)) { if (mfwenable && master && (*detIndex==0)) {
masterFileName = BinaryFileStatic::CreateMasterFileName(filePath, masterFileName = BinaryFileStatic::CreateMasterFileName(*filePath,
fileNamePrefix, *fileIndex); *fileNamePrefix, *fileIndex);
if(!(*silentMode)) { if(!(*silentMode)) {
FILE_LOG(logINFO) << "Master File: " << masterFileName; FILE_LOG(logINFO) << "Master File: " << masterFileName;
} }

View File

@ -173,7 +173,7 @@ void DataProcessor::SetFileFormat(const fileFormat f) {
//remember the pointer values before they are destroyed //remember the pointer values before they are destroyed
int nd[MAX_DIMENSIONS];nd[0] = 0; nd[1] = 0; int nd[MAX_DIMENSIONS];nd[0] = 0; nd[1] = 0;
uint32_t* maxf = nullptr; uint32_t* maxf = nullptr;
char* fname=nullptr; char* fpath=nullptr; uint64_t* findex=nullptr; std::string* fname=nullptr; std::string* fpath=nullptr; uint64_t* findex=nullptr;
bool* owenable=nullptr; int* dindex=nullptr; int* nunits=nullptr; uint64_t* nf = nullptr; bool* owenable=nullptr; int* dindex=nullptr; int* nunits=nullptr; uint64_t* nf = nullptr;
uint32_t* dr = nullptr; uint32_t* port = nullptr; uint32_t* dr = nullptr; uint32_t* port = nullptr;
file->GetMemberPointerValues(nd, maxf, fname, fpath, findex, file->GetMemberPointerValues(nd, maxf, fname, fpath, findex,
@ -186,7 +186,7 @@ void DataProcessor::SetFileFormat(const fileFormat f) {
void DataProcessor::SetupFileWriter(bool fwe, int* nd, uint32_t* maxf, void DataProcessor::SetupFileWriter(bool fwe, int* nd, uint32_t* maxf,
char* fname, char* fpath, uint64_t* findex, std::string* fname, std::string* fpath, uint64_t* findex,
bool* owenable, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, bool* owenable, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr,
uint32_t* portno, uint32_t* portno,
GeneralData* g) GeneralData* g)

View File

@ -17,7 +17,7 @@ const std::string DataStreamer::TypeName = "DataStreamer";
DataStreamer::DataStreamer(int ind, Fifo* f, uint32_t* dr, ROI* r, DataStreamer::DataStreamer(int ind, Fifo* f, uint32_t* dr, ROI* r,
uint64_t* fi, int fd, char* ajh, int* nd, bool* gpEnable, bool* qe) : uint64_t* fi, int fd, std::string* ajh, int* nd, bool* gpEnable, bool* qe) :
ThreadObject(ind), ThreadObject(ind),
runningFlag(0), runningFlag(0),
generalData(nullptr), generalData(nullptr),

View File

@ -10,7 +10,7 @@
File::File(int ind, uint32_t* maxf, File::File(int ind, uint32_t* maxf,
int* nd, char* fname, char* fpath, uint64_t* findex, bool* owenable, int* nd, std::string* fname, std::string* fpath, uint64_t* findex, bool* owenable,
int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno,
bool* smode): bool* smode):
index(ind), index(ind),
@ -64,7 +64,7 @@ void File::PrintMembers(TLogLevel level) {
} }
void File::GetMemberPointerValues(int* nd, uint32_t*& maxf, char*& fname, char*& fpath, uint64_t*& findex, bool*& owenable, void File::GetMemberPointerValues(int* nd, uint32_t*& maxf, std::string*& fname, std::string*& fpath, uint64_t*& findex, bool*& owenable,
int*& dindex, int*& nunits, uint64_t*& nf, uint32_t*& dr, uint32_t*& portno) int*& dindex, int*& nunits, uint64_t*& nf, uint32_t*& dr, uint32_t*& portno)
{ {
nd[0] = numDetX; nd[0] = numDetX;

View File

@ -20,7 +20,7 @@ hid_t HDF5File::virtualfd = 0;
HDF5File::HDF5File(int ind, uint32_t* maxf, HDF5File::HDF5File(int ind, uint32_t* maxf,
int* nd, char* fname, char* fpath, uint64_t* findex, bool* owenable, int* nd, std::string* fname, std::string* fpath, uint64_t* findex, bool* owenable,
int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno,
uint32_t nx, uint32_t ny, uint32_t nx, uint32_t ny,
bool* smode): bool* smode):
@ -132,7 +132,7 @@ int HDF5File::CreateFile() {
numFilesinAcquisition++; numFilesinAcquisition++;
numFramesInFile = 0; numFramesInFile = 0;
numActualPacketsInFile = 0; numActualPacketsInFile = 0;
currentFileName = HDF5FileStatic::CreateFileName(filePath, fileNamePrefix, *fileIndex, currentFileName = HDF5FileStatic::CreateFileName(*filePath, *fileNamePrefix, *fileIndex,
subFileIndex, *detIndex, *numUnitsPerDetector, index); subFileIndex, *detIndex, *numUnitsPerDetector, index);
//first time //first time
@ -249,8 +249,8 @@ int HDF5File::CreateMasterFile(bool mfwenable, masterAttributes& attr) {
if (mfwenable && master && (*detIndex==0)) { if (mfwenable && master && (*detIndex==0)) {
virtualfd = 0; virtualfd = 0;
masterFileName = HDF5FileStatic::CreateMasterFileName(filePath, masterFileName = HDF5FileStatic::CreateMasterFileName(*filePath,
fileNamePrefix, *fileIndex); *fileNamePrefix, *fileIndex);
if(!(*silentMode)) { if(!(*silentMode)) {
FILE_LOG(logINFO) << "Master File: " << masterFileName; FILE_LOG(logINFO) << "Master File: " << masterFileName;
} }
@ -289,14 +289,14 @@ void HDF5File::EndofAcquisition(bool anyPacketsCaught, uint64_t numf) {
int HDF5File::CreateVirtualFile(uint64_t numf) { int HDF5File::CreateVirtualFile(uint64_t numf) {
pthread_mutex_lock(&Mutex); pthread_mutex_lock(&Mutex);
std::string vname = HDF5FileStatic::CreateVirtualFileName(filePath, fileNamePrefix, *fileIndex); std::string vname = HDF5FileStatic::CreateVirtualFileName(*filePath, *fileNamePrefix, *fileIndex);
if(!(*silentMode)) { if(!(*silentMode)) {
FILE_LOG(logINFO) << "Virtual File: " << vname; FILE_LOG(logINFO) << "Virtual File: " << vname;
} }
int ret = HDF5FileStatic::CreateVirtualDataFile(vname, int ret = HDF5FileStatic::CreateVirtualDataFile(vname,
virtualfd, masterFileName, virtualfd, masterFileName,
filePath, fileNamePrefix, *fileIndex, (*numImages > 1), *filePath, *fileNamePrefix, *fileIndex, (*numImages > 1),
*detIndex, *numUnitsPerDetector, *detIndex, *numUnitsPerDetector,
// infinite images in 1 file, then maxfrperfile = numf // infinite images in 1 file, then maxfrperfile = numf
((*maxFramesPerFile == 0) ? numf+1 : *maxFramesPerFile), ((*maxFramesPerFile == 0) ? numf+1 : *maxFramesPerFile),

View File

@ -25,7 +25,7 @@ void sigInterruptHandler(int p){
/* /*
#define PRINT_IN_COLOR(c,f, ...) printf ("\033[%dm" f RESET, 30 + c+1, ##__VA_ARGS__) #define PRINT_IN_COLOR(c,f, ...) printf ("\033[%dm" f RESET, 30 + c+1, ##__VA_ARGS__)
int StartAcq(char* filepath, char* filename, uint64_t fileindex, uint32_t datasize, void*p){ int StartAcq(std::string filepath, std::string filename, uint64_t fileindex, uint32_t datasize, void*p){
FILE_LOG(logINFO) << "#### StartAcq: " FILE_LOG(logINFO) << "#### StartAcq: "
"filepath: " << filepath << "filename: " << filename << "filepath: " << filepath << "filename: " << filename <<
"fileindex: " << fileindex << "datasize: " << datasize << " ####"; "fileindex: " << fileindex << "datasize: " << datasize << " ####";
@ -112,7 +112,7 @@ int main(int argc, char *argv[]) {
1 callback writes file, we have to open, close it 1 callback writes file, we have to open, close it
2 we open, close, write file, callback does not do anything 2 we open, close, write file, callback does not do anything
registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg); registerCallBackStartAcquisition(int (*func)(std::string, std::string, int, int, void*),void *arg);
*/ */
//receiver->registerCallBackStartAcquisition(startAcquisitionCallBack,NULL); //receiver->registerCallBackStartAcquisition(startAcquisitionCallBack,NULL);

View File

@ -69,11 +69,8 @@ void printHelp() {
* @param p pointer to object * @param p pointer to object
* \returns ignored * \returns ignored
*/ */
int StartAcq(char* filepath, char* filename, uint64_t fileindex, uint32_t datasize, void*p){ int StartAcq(std::string filepath, std::string filename, uint64_t fileindex, uint32_t datasize, void*p){
cprintf(BLUE, "#### StartAcq: filepath:%s filename:%s fileindex:%llu datasize:%u ####\n", FILE_LOG(logINFOBLUE) << "#### StartAcq: filepath:" << filepath << " filename:" << filename << " fileindex:" << fileindex << " datasize:" << datasize << " ####";
filepath, filename, (long long unsigned int)fileindex, datasize);
cprintf(BLUE, "--StartAcq: returning 0\n");
return 0; return 0;
} }
@ -83,7 +80,7 @@ int StartAcq(char* filepath, char* filename, uint64_t fileindex, uint32_t datasi
* @param p pointer to object * @param p pointer to object
*/ */
void AcquisitionFinished(uint64_t frames, void*p){ void AcquisitionFinished(uint64_t frames, void*p){
cprintf(BLUE, "#### AcquisitionFinished: frames:%llu ####\n",(long long unsigned int)frames); FILE_LOG(logINFOBLUE) << "#### AcquisitionFinished: frames:" << frames << " ####";
} }

View File

@ -104,7 +104,7 @@ int64_t slsReceiver::getReceiverVersion(){
void slsReceiver::registerCallBackStartAcquisition(int (*func)( void slsReceiver::registerCallBackStartAcquisition(int (*func)(
char*, char*, uint64_t, uint32_t, void*),void *arg){ std::string, std::string, uint64_t, uint32_t, void*),void *arg){
tcpipInterface->registerCallBackStartAcquisition(func,arg); tcpipInterface->registerCallBackStartAcquisition(func,arg);
} }

View File

@ -1,11 +1,3 @@
/********************************************/ /**
* @file
*slsReceiverImplementation.cpp
* @short does all the functions
*for a receiver, set/get
*parameters, start/stop etc.
***********************************************/
#include "slsReceiverImplementation.h" #include "slsReceiverImplementation.h"
#include "DataProcessor.h" #include "DataProcessor.h"
#include "DataStreamer.h" #include "DataStreamer.h"
@ -57,7 +49,6 @@ void slsReceiverImplementation::InitializeMembers() {
for (int i = 0; i < MAX_DIMENSIONS; ++i) for (int i = 0; i < MAX_DIMENSIONS; ++i)
numDet[i] = 0; numDet[i] = 0;
detID = 0; detID = 0;
strcpy(detHostname, "");
acquisitionPeriod = SAMPLE_TIME_IN_NS; acquisitionPeriod = SAMPLE_TIME_IN_NS;
acquisitionTime = 0; acquisitionTime = 0;
subExpTime = 0; subExpTime = 0;
@ -96,8 +87,7 @@ void slsReceiverImplementation::InitializeMembers() {
//***file parameters*** //***file parameters***
fileFormatType = BINARY; fileFormatType = BINARY;
strcpy(fileName, "run"); fileName = "run";
strcpy(filePath, "");
fileIndex = 0; fileIndex = 0;
framesPerFile = 0; framesPerFile = 0;
fileWriteEnable = true; fileWriteEnable = true;
@ -113,7 +103,6 @@ void slsReceiverImplementation::InitializeMembers() {
dataStreamEnable = false; dataStreamEnable = false;
streamingPort = 0; streamingPort = 0;
streamingSrcIP = 0u; streamingSrcIP = 0u;
memset(additionalJsonHeader, 0, sizeof(additionalJsonHeader));
//** class objects *** //** class objects ***
generalData = nullptr; generalData = nullptr;
@ -146,7 +135,7 @@ int slsReceiverImplementation::getDetectorPositionId() const {
std::string slsReceiverImplementation::getDetectorHostname() const { std::string slsReceiverImplementation::getDetectorHostname() const {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
return std::string(detHostname); return detHostname;
} }
int slsReceiverImplementation::getFlippedDataX() const { int slsReceiverImplementation::getFlippedDataX() const {
@ -183,12 +172,12 @@ slsDetectorDefs::fileFormat slsReceiverImplementation::getFileFormat() const {
std::string slsReceiverImplementation::getFileName() const { std::string slsReceiverImplementation::getFileName() const {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
return std::string(fileName); return fileName;
} }
std::string slsReceiverImplementation::getFilePath() const { std::string slsReceiverImplementation::getFilePath() const {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
return std::string(filePath); return filePath;
} }
uint64_t slsReceiverImplementation::getFileIndex() const { uint64_t slsReceiverImplementation::getFileIndex() const {
@ -405,7 +394,7 @@ sls::IpAddr slsReceiverImplementation::getStreamingSourceIP() const {
std::string slsReceiverImplementation::getAdditionalJsonHeader() const { std::string slsReceiverImplementation::getAdditionalJsonHeader() const {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
return std::string(additionalJsonHeader); return additionalJsonHeader;
} }
int64_t slsReceiverImplementation::getUDPSocketBufferSize() const { int64_t slsReceiverImplementation::getUDPSocketBufferSize() const {
@ -425,11 +414,11 @@ int64_t slsReceiverImplementation::getActualUDPSocketBufferSize() const {
/**initial parameters***/ /**initial parameters***/
void slsReceiverImplementation::setDetectorHostname(const char *c) { void slsReceiverImplementation::setDetectorHostname(const std::string& c) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
if (strlen(c)) if (!c.empty())
strcpy(detHostname, c); detHostname = c;
FILE_LOG(logINFO) << "Detector Hostname: " << detHostname; FILE_LOG(logINFO) << "Detector Hostname: " << detHostname;
} }
@ -572,20 +561,20 @@ void slsReceiverImplementation::setFileFormat(const fileFormat f) {
FILE_LOG(logINFO) << "File Format: " << sls::ToString(fileFormatType); FILE_LOG(logINFO) << "File Format: " << sls::ToString(fileFormatType);
} }
void slsReceiverImplementation::setFileName(const char c[]) { void slsReceiverImplementation::setFileName(const std::string& c) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
if (strlen(c)) if (!c.empty())
strcpy(fileName, c); fileName = c;
FILE_LOG(logINFO) << "File name: " << fileName; FILE_LOG(logINFO) << "File name: " << fileName;
} }
void slsReceiverImplementation::setFilePath(const char c[]) { void slsReceiverImplementation::setFilePath(const std::string& c) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
if (strlen(c)) { if (!c.empty()) {
mkdir_p(c); //throws if it can't create mkdir_p(c); //throws if it can't create
strcpy(filePath, c); filePath = c;
} }
FILE_LOG(logINFO) << "File path: " << filePath; FILE_LOG(logINFO) << "File path: " << filePath;
} }
@ -627,8 +616,8 @@ void slsReceiverImplementation::setFileWriteEnable(const bool b) {
fileWriteEnable = b; fileWriteEnable = b;
for (unsigned int i = 0; i < dataProcessor.size(); ++i) { for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
dataProcessor[i]->SetupFileWriter( dataProcessor[i]->SetupFileWriter(
fileWriteEnable, (int *)numDet, &framesPerFile, fileName, fileWriteEnable, (int *)numDet, &framesPerFile, &fileName,
filePath, &fileIndex, &overwriteEnable, &detID, &numThreads, &filePath, &fileIndex, &overwriteEnable, &detID, &numThreads,
&numberOfFrames, &dynamicRange, &udpPortNum[i], generalData); &numberOfFrames, &dynamicRange, &udpPortNum[i], generalData);
} }
} }
@ -747,7 +736,7 @@ int slsReceiverImplementation::setNumberofUDPInterfaces(const int n) {
} }
dataStreamer.push_back(sls::make_unique<DataStreamer>( dataStreamer.push_back(sls::make_unique<DataStreamer>(
i, fifo[i].get(), &dynamicRange, &roi, &fileIndex, i, fifo[i].get(), &dynamicRange, &roi, &fileIndex,
fd, additionalJsonHeader, (int*)nd, &gapPixelsEnable, &quadEnable)); fd, &additionalJsonHeader, (int*)nd, &gapPixelsEnable, &quadEnable));
dataStreamer[i]->SetGeneralData(generalData); dataStreamer[i]->SetGeneralData(generalData);
dataStreamer[i]->CreateZmqSockets( dataStreamer[i]->CreateZmqSockets(
&numThreads, streamingPort, streamingSrcIP); &numThreads, streamingPort, streamingSrcIP);
@ -889,7 +878,7 @@ int slsReceiverImplementation::setDataStreamEnable(const bool enable) {
} }
dataStreamer.push_back(sls::make_unique<DataStreamer>( dataStreamer.push_back(sls::make_unique<DataStreamer>(
i, fifo[i].get(), &dynamicRange, &roi, &fileIndex, i, fifo[i].get(), &dynamicRange, &roi, &fileIndex,
fd, additionalJsonHeader, (int*)nd, &gapPixelsEnable, &quadEnable)); fd, &additionalJsonHeader, (int*)nd, &gapPixelsEnable, &quadEnable));
dataStreamer[i]->SetGeneralData(generalData); dataStreamer[i]->SetGeneralData(generalData);
dataStreamer[i]->CreateZmqSockets( dataStreamer[i]->CreateZmqSockets(
&numThreads, streamingPort, streamingSrcIP); &numThreads, streamingPort, streamingSrcIP);
@ -918,9 +907,9 @@ void slsReceiverImplementation::setStreamingSourceIP(const sls::IpAddr ip) {
FILE_LOG(logINFO) << "Streaming Source IP: " << streamingSrcIP; FILE_LOG(logINFO) << "Streaming Source IP: " << streamingSrcIP;
} }
void slsReceiverImplementation::setAdditionalJsonHeader(const char c[]) { void slsReceiverImplementation::setAdditionalJsonHeader(const std::string& c) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
strcpy(additionalJsonHeader, c); additionalJsonHeader = c;
FILE_LOG(logINFO) << "Additional JSON Header: " << additionalJsonHeader; FILE_LOG(logINFO) << "Additional JSON Header: " << additionalJsonHeader;
} }
@ -1194,7 +1183,7 @@ void slsReceiverImplementation::setDetectorPositionId(const int id) {
FILE_LOG(logINFO) << "Detector Position Id:" << detID; FILE_LOG(logINFO) << "Detector Position Id:" << detID;
for (unsigned int i = 0; i < dataProcessor.size(); ++i) { for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
dataProcessor[i]->SetupFileWriter( dataProcessor[i]->SetupFileWriter(
fileWriteEnable, (int *)numDet, &framesPerFile, fileName, filePath, fileWriteEnable, (int *)numDet, &framesPerFile, &fileName, &filePath,
&fileIndex, &overwriteEnable, &detID, &numThreads, &numberOfFrames, &fileIndex, &overwriteEnable, &detID, &numThreads, &numberOfFrames,
&dynamicRange, &udpPortNum[i], generalData); &dynamicRange, &udpPortNum[i], generalData);
} }
@ -1209,15 +1198,15 @@ void slsReceiverImplementation::setDetectorPositionId(const int id) {
} }
int slsReceiverImplementation::startReceiver(char *c) { int slsReceiverImplementation::startReceiver(std::string& err) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
FILE_LOG(logINFO) << "Starting Receiver"; FILE_LOG(logINFO) << "Starting Receiver";
ResetParametersforNewAcquisition(); ResetParametersforNewAcquisition();
// listener // listener
if (CreateUDPSockets() == FAIL) { if (CreateUDPSockets() == FAIL) {
strcpy(c, "Could not create UDP Socket(s)."); err.assign("Could not create UDP Socket(s).");
FILE_LOG(logERROR) << c; FILE_LOG(logERROR) << err;
return FAIL; return FAIL;
} }
@ -1235,8 +1224,8 @@ int slsReceiverImplementation::startReceiver(char *c) {
// processor->writer // processor->writer
if (fileWriteEnable) { if (fileWriteEnable) {
if (SetupWriter() == FAIL) { if (SetupWriter() == FAIL) {
strcpy(c, "Could not create file.\n"); err.assign("Could not create file.\n");
FILE_LOG(logERROR) << c; FILE_LOG(logERROR) << err;
return FAIL; return FAIL;
} }
} else } else
@ -1417,7 +1406,7 @@ int slsReceiverImplementation::restreamStop() {
/***callback functions***/ /***callback functions***/
void slsReceiverImplementation::registerCallBackStartAcquisition( void slsReceiverImplementation::registerCallBackStartAcquisition(
int (*func)(char *, char *, uint64_t, uint32_t, void *), void *arg) { int (*func)(std::string, std::string, uint64_t, uint32_t, void *), void *arg) {
startAcquisitionCallBack = func; startAcquisitionCallBack = func;
pStartAcquisition = arg; pStartAcquisition = arg;
} }
@ -1537,9 +1526,9 @@ void slsReceiverImplementation::ResetParametersforNewAcquisition() {
it->ResetParametersforNewAcquisition(); it->ResetParametersforNewAcquisition();
if (dataStreamEnable) { if (dataStreamEnable) {
char fnametostream[MAX_STR_LENGTH * 2]; std::ostringstream os;
snprintf(fnametostream, MAX_STR_LENGTH * 2, "%s/%s", filePath, os << filePath << '/' << fileName;
fileName); std::string fnametostream = os.str();
for (const auto &it : dataStreamer) for (const auto &it : dataStreamer)
it->ResetParametersforNewAcquisition(fnametostream); it->ResetParametersforNewAcquisition(fnametostream);
} }

View File

@ -69,7 +69,7 @@ int64_t slsReceiverTCPIPInterface::getReceiverVersion() { return APIRECEIVER; }
/***callback functions***/ /***callback functions***/
void slsReceiverTCPIPInterface::registerCallBackStartAcquisition( void slsReceiverTCPIPInterface::registerCallBackStartAcquisition(
int (*func)(char *, char *, uint64_t, uint32_t, void *), void *arg) { int (*func)(std::string, std::string, uint64_t, uint32_t, void *), void *arg) {
startAcquisitionCallBack = func; startAcquisitionCallBack = func;
pStartAcquisition = arg; pStartAcquisition = arg;
} }
@ -112,6 +112,7 @@ void slsReceiverTCPIPInterface::startTCPServer() {
ret = decode_function(socket); ret = decode_function(socket);
} catch (const RuntimeError &e) { } catch (const RuntimeError &e) {
// We had an error needs to be sent to client // We had an error needs to be sent to client
char mess[MAX_STR_LENGTH]{};
sls::strcpy_safe(mess, e.what()); sls::strcpy_safe(mess, e.what());
socket.Send(FAIL); socket.Send(FAIL);
socket.Send(mess); socket.Send(mess);
@ -274,9 +275,10 @@ void slsReceiverTCPIPInterface::VerifyLock() {
void slsReceiverTCPIPInterface::VerifyIdle(Interface &socket) { void slsReceiverTCPIPInterface::VerifyIdle(Interface &socket) {
if (impl()->getStatus() != IDLE) { if (impl()->getStatus() != IDLE) {
// sprintf(mess, "Can not execute %s when receiver is not idle\n", std::ostringstream oss;
// getFunctionNameFromEnum((enum detFuncs)fnum)); oss << "Can not execute " << getFunctionNameFromEnum((enum detFuncs)fnum)
throw sls::SocketError(mess); << " when receiver is not idle";
throw sls::SocketError(oss.str());
} }
} }
@ -656,9 +658,10 @@ int slsReceiverTCPIPInterface::get_status(Interface &socket) {
int slsReceiverTCPIPInterface::start_receiver(Interface &socket) { int slsReceiverTCPIPInterface::start_receiver(Interface &socket) {
if (impl()->getStatus() == IDLE) { if (impl()->getStatus() == IDLE) {
FILE_LOG(logDEBUG1) << "Starting Receiver"; FILE_LOG(logDEBUG1) << "Starting Receiver";
ret = impl()->startReceiver(mess); std::string err;
ret = impl()->startReceiver(err);
if (ret == FAIL) { if (ret == FAIL) {
throw RuntimeError(mess); throw RuntimeError(err);
} }
} }
return socket.Send(OK); return socket.Send(OK);
@ -852,8 +855,6 @@ int slsReceiverTCPIPInterface::set_streaming_timer(Interface &socket) {
} }
int slsReceiverTCPIPInterface::set_flipped_data(Interface &socket) { int slsReceiverTCPIPInterface::set_flipped_data(Interface &socket) {
// TODO! Why 2 args?
memset(mess, 0, sizeof(mess));
auto arg = socket.Receive<int>(); auto arg = socket.Receive<int>();
if (myDetectorType != EIGER) if (myDetectorType != EIGER)
@ -983,7 +984,6 @@ int slsReceiverTCPIPInterface::restream_stop(Interface &socket) {
} }
int slsReceiverTCPIPInterface::set_additional_json_header(Interface &socket) { int slsReceiverTCPIPInterface::set_additional_json_header(Interface &socket) {
memset(mess, 0, sizeof(mess));
char arg[MAX_STR_LENGTH]{}; char arg[MAX_STR_LENGTH]{};
char retval[MAX_STR_LENGTH]{}; char retval[MAX_STR_LENGTH]{};
socket.Receive(arg); socket.Receive(arg);

View File

@ -28,7 +28,7 @@ int64_t slsReceiverUsers::getReceiverVersion(){
return receiver->getReceiverVersion(); return receiver->getReceiverVersion();
} }
void slsReceiverUsers::registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg){ void slsReceiverUsers::registerCallBackStartAcquisition(int (*func)(std::string, std::string, uint64_t, uint32_t, void*),void *arg){
receiver->registerCallBackStartAcquisition(func,arg); receiver->registerCallBackStartAcquisition(func,arg);
} }

View File

@ -278,7 +278,7 @@ public:
uint32_t debug = 0, uint16_t roundRNumber = 0, uint32_t debug = 0, uint16_t roundRNumber = 0,
uint8_t detType = 0, uint8_t version = 0, int gapPixelsEnable = 0, int flippedDataX = 0, uint8_t detType = 0, uint8_t version = 0, int gapPixelsEnable = 0, int flippedDataX = 0,
uint32_t quadEnable = 0, uint32_t quadEnable = 0,
char* additionalJsonHeader = 0) { std::string* additionalJsonHeader = 0) {
@ -331,9 +331,9 @@ public:
quadEnable quadEnable
); );
if (additionalJsonHeader && strlen(additionalJsonHeader)) { if (additionalJsonHeader && !((*additionalJsonHeader).empty())) {
strcat(buf, ", "); strcat(buf, ", ");
strcat(buf, additionalJsonHeader); strcat(buf, (*additionalJsonHeader).c_str());
} }
strcat(buf, "}\n"); strcat(buf, "}\n");
int length = strlen(buf); int length = strlen(buf);