diff --git a/slsReceiverSoftware/include/BinaryFile.h b/slsReceiverSoftware/include/BinaryFile.h index 6178d728c..2b3535bbf 100755 --- a/slsReceiverSoftware/include/BinaryFile.h +++ b/slsReceiverSoftware/include/BinaryFile.h @@ -35,7 +35,7 @@ class BinaryFile : private virtual slsDetectorDefs, public File, public BinaryFi * @param smode pointer to silent mode */ 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, bool* smode); diff --git a/slsReceiverSoftware/include/BinaryFileStatic.h b/slsReceiverSoftware/include/BinaryFileStatic.h index d80cfcc33..29483adef 100755 --- a/slsReceiverSoftware/include/BinaryFileStatic.h +++ b/slsReceiverSoftware/include/BinaryFileStatic.h @@ -40,7 +40,7 @@ class BinaryFileStatic { * @param unitindex unit index * @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, int dindex, int numunits = 1, int unitindex = 0) { @@ -58,7 +58,7 @@ class BinaryFileStatic { * @param findex file index * @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) { std::ostringstream os; os << fpath << "/" << fnameprefix << "_master" diff --git a/slsReceiverSoftware/include/DataProcessor.h b/slsReceiverSoftware/include/DataProcessor.h index 4716580f0..893c74466 100755 --- a/slsReceiverSoftware/include/DataProcessor.h +++ b/slsReceiverSoftware/include/DataProcessor.h @@ -147,8 +147,8 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject { * @param portno pointer to udp port number * @param g address of GeneralData (Detector Data) pointer */ - void SetupFileWriter(bool fwe, int* nd, uint32_t* maxf, char* fname, - char* fpath, uint64_t* findex, + void SetupFileWriter(bool fwe, 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, GeneralData* g = nullptr); diff --git a/slsReceiverSoftware/include/DataStreamer.h b/slsReceiverSoftware/include/DataStreamer.h index 94cbc13bb..59a68ea22 100755 --- a/slsReceiverSoftware/include/DataStreamer.h +++ b/slsReceiverSoftware/include/DataStreamer.h @@ -35,7 +35,7 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject { * @param qe pointer to quad Enable */ 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 @@ -197,7 +197,7 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject { int flippedDataX; /** additional json header */ - char* additionJsonHeader; + std::string* additionJsonHeader; /** Aquisition Started flag */ bool startedFlag; diff --git a/slsReceiverSoftware/include/File.h b/slsReceiverSoftware/include/File.h index 02a43c8e0..7d11dd77b 100755 --- a/slsReceiverSoftware/include/File.h +++ b/slsReceiverSoftware/include/File.h @@ -36,7 +36,7 @@ class File : private virtual slsDetectorDefs { * @param smode pointer to silent mode */ 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, bool* smode); @@ -78,7 +78,7 @@ class File : private virtual slsDetectorDefs { * @param dr 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, int*& dindex, int*& nunits, uint64_t*& nf, uint32_t*& dr, uint32_t*& portno); @@ -161,10 +161,10 @@ class File : private virtual slsDetectorDefs { int numDetY; /** File Name Prefix */ - char* fileNamePrefix; + std::string* fileNamePrefix; /** File Path */ - char* filePath; + std::string* filePath; /** File Index */ uint64_t* fileIndex; diff --git a/slsReceiverSoftware/include/HDF5File.h b/slsReceiverSoftware/include/HDF5File.h index c3727109e..65bfba2eb 100755 --- a/slsReceiverSoftware/include/HDF5File.h +++ b/slsReceiverSoftware/include/HDF5File.h @@ -42,7 +42,7 @@ class HDF5File : private virtual slsDetectorDefs, public File, public HDF5FileSt * @param smode pointer to silent mode */ 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, uint32_t nx, uint32_t ny, bool* smode); diff --git a/slsReceiverSoftware/include/HDF5FileStatic.h b/slsReceiverSoftware/include/HDF5FileStatic.h index a9fc3fdc2..2cdc0a810 100755 --- a/slsReceiverSoftware/include/HDF5FileStatic.h +++ b/slsReceiverSoftware/include/HDF5FileStatic.h @@ -46,7 +46,7 @@ public: * @param unitindex unit index * @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, int dindex, int numunits = 1, int unitindex = 0) { @@ -64,7 +64,7 @@ public: * @param findex file index * @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; os << fpath << "/" << fnameprefix << "_master" @@ -80,7 +80,7 @@ public: * @param findex file index * @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; osfn << fpath << "/" << fnameprefix; @@ -584,7 +584,7 @@ public: static int CreateVirtualDataFile( std::string virtualFileName, 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, uint32_t maxFramesPerFile, uint64_t numf, std::string srcDataseName, DataType dataType, diff --git a/slsReceiverSoftware/include/slsReceiver.h b/slsReceiverSoftware/include/slsReceiver.h index e7f14685f..a87c37d49 100755 --- a/slsReceiverSoftware/include/slsReceiver.h +++ b/slsReceiverSoftware/include/slsReceiver.h @@ -65,7 +65,7 @@ class slsReceiver : private virtual slsDetectorDefs { * we write depending on file write enable * 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 diff --git a/slsReceiverSoftware/include/slsReceiverImplementation.h b/slsReceiverSoftware/include/slsReceiverImplementation.h index ace742ca5..23ac7070a 100755 --- a/slsReceiverSoftware/include/slsReceiverImplementation.h +++ b/slsReceiverSoftware/include/slsReceiverImplementation.h @@ -60,7 +60,7 @@ class slsReceiverImplementation : private virtual slsDetectorDefs { /* * Get detector hostname - * @return hostname (max of 1000 characters) + * @return hostname */ std::string getDetectorHostname() const; @@ -376,7 +376,7 @@ class slsReceiverImplementation : private virtual slsDetectorDefs { * Sets detector hostname * @param c detector hostname */ - void setDetectorHostname(const char *c); + void setDetectorHostname(const std::string& c); /* * Set multi detector size @@ -428,17 +428,17 @@ class slsReceiverImplementation : private virtual slsDetectorDefs { * Set File Name Prefix (without frame index, file index and extension * (_d0_f000000000000_8.raw)) Does not check for file existence since it is * 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 * Checks for file directory existence before setting file path, * 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 @@ -570,7 +570,7 @@ class slsReceiverImplementation : private virtual slsDetectorDefs { /** * Set additional json header */ - void setAdditionalJsonHeader(const char *c); + void setAdditionalJsonHeader(const std::string& c); /** * Set Acquisition Period @@ -708,7 +708,7 @@ class slsReceiverImplementation : private virtual slsDetectorDefs { * @param c error message if FAIL * @return OK or FAIL */ - int startReceiver(char *c = NULL); + int startReceiver(std::string& err); /** * Stop Listening for Packets @@ -760,7 +760,7 @@ class slsReceiverImplementation : private virtual slsDetectorDefs { * we write depending on file write enable * 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 *), void *arg); @@ -860,7 +860,7 @@ class slsReceiverImplementation : private virtual slsDetectorDefs { /*Detector Readout ID*/ int detID; /** detector hostname */ - char detHostname[MAX_STR_LENGTH]; + std::string detHostname; /** Acquisition Period */ uint64_t acquisitionPeriod; /** Acquisition Time */ @@ -932,10 +932,10 @@ class slsReceiverImplementation : private virtual slsDetectorDefs { /** File format */ fileFormat fileFormatType; /** File Name without frame index, file index and extension - * (_d0_f000000000000_8.raw)*/ - char fileName[MAX_STR_LENGTH]; + * (_d0_f0_8.raw)*/ + std::string fileName; /** File Path */ - char filePath[MAX_STR_LENGTH]; + std::string filePath; /** File Index */ uint64_t fileIndex; /** Frames per file (0 means infinite) */ @@ -963,7 +963,7 @@ class slsReceiverImplementation : private virtual slsDetectorDefs { /** streaming port */ sls::IpAddr streamingSrcIP; /** additional json header */ - char additionalJsonHeader[MAX_STR_LENGTH]; + std::string additionalJsonHeader; //** class objects *** /** General Data Properties */ @@ -990,7 +990,7 @@ class slsReceiverImplementation : private virtual slsDetectorDefs { * we write depending on file write enable * 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; /** * Call back for acquisition finished diff --git a/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h b/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h index 199da818e..92c6efd63 100755 --- a/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h +++ b/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h @@ -60,7 +60,7 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs { * we write depending on file write enable * 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 *), void *arg); @@ -338,9 +338,6 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs { int (slsReceiverTCPIPInterface::*flist[NUM_REC_FUNCTIONS])( sls::ServerInterface2 &socket); - /** Message */ - char mess[MAX_STR_LENGTH]{}; - /** success/failure */ int ret{OK}; @@ -375,7 +372,7 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs { * we write depending on file write enable * 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 *pStartAcquisition{nullptr}; diff --git a/slsReceiverSoftware/include/slsReceiverUsers.h b/slsReceiverSoftware/include/slsReceiverUsers.h index 39456bd94..76c939db7 100755 --- a/slsReceiverSoftware/include/slsReceiverUsers.h +++ b/slsReceiverSoftware/include/slsReceiverUsers.h @@ -55,7 +55,7 @@ public: \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 */ - 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); /** diff --git a/slsReceiverSoftware/src/BinaryFile.cpp b/slsReceiverSoftware/src/BinaryFile.cpp index 78caee98f..eb3f36341 100755 --- a/slsReceiverSoftware/src/BinaryFile.cpp +++ b/slsReceiverSoftware/src/BinaryFile.cpp @@ -14,7 +14,7 @@ FILE* BinaryFile::masterfd = nullptr; 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, bool* smode): File(ind, maxf, nd, fname, fpath, findex, owenable, dindex, nunits, nf, dr, portno, smode), @@ -46,7 +46,7 @@ int BinaryFile::CreateFile() { numFramesInFile = 0; numActualPacketsInFile = 0; - currentFileName = BinaryFileStatic::CreateFileName(filePath, fileNamePrefix, *fileIndex, + currentFileName = BinaryFileStatic::CreateFileName(*filePath, *fileNamePrefix, *fileIndex, subFileIndex, *detIndex, *numUnitsPerDetector, index); if (BinaryFileStatic::CreateDataFile(filefd, *overWriteEnable, currentFileName, FILE_BUFFER_SIZE) == FAIL) @@ -120,8 +120,8 @@ int BinaryFile::CreateMasterFile(bool mfwenable, masterAttributes& attr) { numActualPacketsInFile = 0; if (mfwenable && master && (*detIndex==0)) { - masterFileName = BinaryFileStatic::CreateMasterFileName(filePath, - fileNamePrefix, *fileIndex); + masterFileName = BinaryFileStatic::CreateMasterFileName(*filePath, + *fileNamePrefix, *fileIndex); if(!(*silentMode)) { FILE_LOG(logINFO) << "Master File: " << masterFileName; } diff --git a/slsReceiverSoftware/src/DataProcessor.cpp b/slsReceiverSoftware/src/DataProcessor.cpp index 0464c652f..15320bf6c 100755 --- a/slsReceiverSoftware/src/DataProcessor.cpp +++ b/slsReceiverSoftware/src/DataProcessor.cpp @@ -173,7 +173,7 @@ void DataProcessor::SetFileFormat(const fileFormat f) { //remember the pointer values before they are destroyed int nd[MAX_DIMENSIONS];nd[0] = 0; nd[1] = 0; 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; uint32_t* dr = nullptr; uint32_t* port = nullptr; 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, - 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, uint32_t* portno, GeneralData* g) diff --git a/slsReceiverSoftware/src/DataStreamer.cpp b/slsReceiverSoftware/src/DataStreamer.cpp index b0cac787e..039c7f720 100755 --- a/slsReceiverSoftware/src/DataStreamer.cpp +++ b/slsReceiverSoftware/src/DataStreamer.cpp @@ -17,7 +17,7 @@ const std::string DataStreamer::TypeName = "DataStreamer"; 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), runningFlag(0), generalData(nullptr), diff --git a/slsReceiverSoftware/src/File.cpp b/slsReceiverSoftware/src/File.cpp index e0d439ee3..5d1ab0561 100755 --- a/slsReceiverSoftware/src/File.cpp +++ b/slsReceiverSoftware/src/File.cpp @@ -10,7 +10,7 @@ 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, bool* smode): 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) { nd[0] = numDetX; diff --git a/slsReceiverSoftware/src/HDF5File.cpp b/slsReceiverSoftware/src/HDF5File.cpp index ec1b07982..512dc6b32 100755 --- a/slsReceiverSoftware/src/HDF5File.cpp +++ b/slsReceiverSoftware/src/HDF5File.cpp @@ -20,7 +20,7 @@ hid_t HDF5File::virtualfd = 0; 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, uint32_t nx, uint32_t ny, bool* smode): @@ -132,7 +132,7 @@ int HDF5File::CreateFile() { numFilesinAcquisition++; numFramesInFile = 0; numActualPacketsInFile = 0; - currentFileName = HDF5FileStatic::CreateFileName(filePath, fileNamePrefix, *fileIndex, + currentFileName = HDF5FileStatic::CreateFileName(*filePath, *fileNamePrefix, *fileIndex, subFileIndex, *detIndex, *numUnitsPerDetector, index); //first time @@ -249,8 +249,8 @@ int HDF5File::CreateMasterFile(bool mfwenable, masterAttributes& attr) { if (mfwenable && master && (*detIndex==0)) { virtualfd = 0; - masterFileName = HDF5FileStatic::CreateMasterFileName(filePath, - fileNamePrefix, *fileIndex); + masterFileName = HDF5FileStatic::CreateMasterFileName(*filePath, + *fileNamePrefix, *fileIndex); if(!(*silentMode)) { FILE_LOG(logINFO) << "Master File: " << masterFileName; } @@ -289,14 +289,14 @@ void HDF5File::EndofAcquisition(bool anyPacketsCaught, uint64_t numf) { int HDF5File::CreateVirtualFile(uint64_t numf) { pthread_mutex_lock(&Mutex); - std::string vname = HDF5FileStatic::CreateVirtualFileName(filePath, fileNamePrefix, *fileIndex); + std::string vname = HDF5FileStatic::CreateVirtualFileName(*filePath, *fileNamePrefix, *fileIndex); if(!(*silentMode)) { FILE_LOG(logINFO) << "Virtual File: " << vname; } int ret = HDF5FileStatic::CreateVirtualDataFile(vname, virtualfd, masterFileName, - filePath, fileNamePrefix, *fileIndex, (*numImages > 1), + *filePath, *fileNamePrefix, *fileIndex, (*numImages > 1), *detIndex, *numUnitsPerDetector, // infinite images in 1 file, then maxfrperfile = numf ((*maxFramesPerFile == 0) ? numf+1 : *maxFramesPerFile), diff --git a/slsReceiverSoftware/src/main.cpp b/slsReceiverSoftware/src/main.cpp index c2fbd0194..fa2f73e49 100755 --- a/slsReceiverSoftware/src/main.cpp +++ b/slsReceiverSoftware/src/main.cpp @@ -25,7 +25,7 @@ void sigInterruptHandler(int p){ /* #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: " "filepath: " << filepath << "filename: " << filename << "fileindex: " << fileindex << "datasize: " << datasize << " ####"; @@ -112,7 +112,7 @@ int main(int argc, char *argv[]) { 1 callback writes file, we have to open, close it 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); diff --git a/slsReceiverSoftware/src/multiReceiver.cpp b/slsReceiverSoftware/src/multiReceiver.cpp index 7762079e5..fa9ecbd49 100755 --- a/slsReceiverSoftware/src/multiReceiver.cpp +++ b/slsReceiverSoftware/src/multiReceiver.cpp @@ -69,11 +69,8 @@ void printHelp() { * @param p pointer to object * \returns ignored */ -int StartAcq(char* filepath, char* filename, uint64_t fileindex, uint32_t datasize, void*p){ - cprintf(BLUE, "#### StartAcq: filepath:%s filename:%s fileindex:%llu datasize:%u ####\n", - filepath, filename, (long long unsigned int)fileindex, datasize); - - cprintf(BLUE, "--StartAcq: returning 0\n"); +int StartAcq(std::string filepath, std::string filename, uint64_t fileindex, uint32_t datasize, void*p){ + FILE_LOG(logINFOBLUE) << "#### StartAcq: filepath:" << filepath << " filename:" << filename << " fileindex:" << fileindex << " datasize:" << datasize << " ####"; return 0; } @@ -83,7 +80,7 @@ int StartAcq(char* filepath, char* filename, uint64_t fileindex, uint32_t datasi * @param p pointer to object */ void AcquisitionFinished(uint64_t frames, void*p){ - cprintf(BLUE, "#### AcquisitionFinished: frames:%llu ####\n",(long long unsigned int)frames); + FILE_LOG(logINFOBLUE) << "#### AcquisitionFinished: frames:" << frames << " ####"; } diff --git a/slsReceiverSoftware/src/slsReceiver.cpp b/slsReceiverSoftware/src/slsReceiver.cpp index 9be63de83..da2b47f93 100755 --- a/slsReceiverSoftware/src/slsReceiver.cpp +++ b/slsReceiverSoftware/src/slsReceiver.cpp @@ -104,7 +104,7 @@ int64_t slsReceiver::getReceiverVersion(){ 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); } diff --git a/slsReceiverSoftware/src/slsReceiverImplementation.cpp b/slsReceiverSoftware/src/slsReceiverImplementation.cpp index 1b7a0d3b7..97b2467f6 100755 --- a/slsReceiverSoftware/src/slsReceiverImplementation.cpp +++ b/slsReceiverSoftware/src/slsReceiverImplementation.cpp @@ -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 "DataProcessor.h" #include "DataStreamer.h" @@ -57,7 +49,6 @@ void slsReceiverImplementation::InitializeMembers() { for (int i = 0; i < MAX_DIMENSIONS; ++i) numDet[i] = 0; detID = 0; - strcpy(detHostname, ""); acquisitionPeriod = SAMPLE_TIME_IN_NS; acquisitionTime = 0; subExpTime = 0; @@ -96,8 +87,7 @@ void slsReceiverImplementation::InitializeMembers() { //***file parameters*** fileFormatType = BINARY; - strcpy(fileName, "run"); - strcpy(filePath, ""); + fileName = "run"; fileIndex = 0; framesPerFile = 0; fileWriteEnable = true; @@ -113,7 +103,6 @@ void slsReceiverImplementation::InitializeMembers() { dataStreamEnable = false; streamingPort = 0; streamingSrcIP = 0u; - memset(additionalJsonHeader, 0, sizeof(additionalJsonHeader)); //** class objects *** generalData = nullptr; @@ -146,7 +135,7 @@ int slsReceiverImplementation::getDetectorPositionId() const { std::string slsReceiverImplementation::getDetectorHostname() const { FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; - return std::string(detHostname); + return detHostname; } int slsReceiverImplementation::getFlippedDataX() const { @@ -183,12 +172,12 @@ slsDetectorDefs::fileFormat slsReceiverImplementation::getFileFormat() const { std::string slsReceiverImplementation::getFileName() const { FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; - return std::string(fileName); + return fileName; } std::string slsReceiverImplementation::getFilePath() const { FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; - return std::string(filePath); + return filePath; } uint64_t slsReceiverImplementation::getFileIndex() const { @@ -405,7 +394,7 @@ sls::IpAddr slsReceiverImplementation::getStreamingSourceIP() const { std::string slsReceiverImplementation::getAdditionalJsonHeader() const { FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; - return std::string(additionalJsonHeader); + return additionalJsonHeader; } int64_t slsReceiverImplementation::getUDPSocketBufferSize() const { @@ -425,11 +414,11 @@ int64_t slsReceiverImplementation::getActualUDPSocketBufferSize() const { /**initial parameters***/ -void slsReceiverImplementation::setDetectorHostname(const char *c) { +void slsReceiverImplementation::setDetectorHostname(const std::string& c) { FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; - if (strlen(c)) - strcpy(detHostname, c); + if (!c.empty()) + detHostname = c; FILE_LOG(logINFO) << "Detector Hostname: " << detHostname; } @@ -572,20 +561,20 @@ void slsReceiverImplementation::setFileFormat(const fileFormat f) { 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"; - if (strlen(c)) - strcpy(fileName, c); + if (!c.empty()) + fileName = c; 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"; - if (strlen(c)) { + if (!c.empty()) { mkdir_p(c); //throws if it can't create - strcpy(filePath, c); + filePath = c; } FILE_LOG(logINFO) << "File path: " << filePath; } @@ -627,8 +616,8 @@ void slsReceiverImplementation::setFileWriteEnable(const bool b) { fileWriteEnable = b; for (unsigned int i = 0; i < dataProcessor.size(); ++i) { dataProcessor[i]->SetupFileWriter( - fileWriteEnable, (int *)numDet, &framesPerFile, fileName, - filePath, &fileIndex, &overwriteEnable, &detID, &numThreads, + fileWriteEnable, (int *)numDet, &framesPerFile, &fileName, + &filePath, &fileIndex, &overwriteEnable, &detID, &numThreads, &numberOfFrames, &dynamicRange, &udpPortNum[i], generalData); } } @@ -747,7 +736,7 @@ int slsReceiverImplementation::setNumberofUDPInterfaces(const int n) { } dataStreamer.push_back(sls::make_unique( 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]->CreateZmqSockets( &numThreads, streamingPort, streamingSrcIP); @@ -889,7 +878,7 @@ int slsReceiverImplementation::setDataStreamEnable(const bool enable) { } dataStreamer.push_back(sls::make_unique( 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]->CreateZmqSockets( &numThreads, streamingPort, streamingSrcIP); @@ -918,9 +907,9 @@ void slsReceiverImplementation::setStreamingSourceIP(const sls::IpAddr ip) { 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"; - strcpy(additionalJsonHeader, c); + additionalJsonHeader = c; FILE_LOG(logINFO) << "Additional JSON Header: " << additionalJsonHeader; } @@ -1194,7 +1183,7 @@ void slsReceiverImplementation::setDetectorPositionId(const int id) { FILE_LOG(logINFO) << "Detector Position Id:" << detID; for (unsigned int i = 0; i < dataProcessor.size(); ++i) { dataProcessor[i]->SetupFileWriter( - fileWriteEnable, (int *)numDet, &framesPerFile, fileName, filePath, + fileWriteEnable, (int *)numDet, &framesPerFile, &fileName, &filePath, &fileIndex, &overwriteEnable, &detID, &numThreads, &numberOfFrames, &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(logINFO) << "Starting Receiver"; ResetParametersforNewAcquisition(); // listener if (CreateUDPSockets() == FAIL) { - strcpy(c, "Could not create UDP Socket(s)."); - FILE_LOG(logERROR) << c; + err.assign("Could not create UDP Socket(s)."); + FILE_LOG(logERROR) << err; return FAIL; } @@ -1235,8 +1224,8 @@ int slsReceiverImplementation::startReceiver(char *c) { // processor->writer if (fileWriteEnable) { if (SetupWriter() == FAIL) { - strcpy(c, "Could not create file.\n"); - FILE_LOG(logERROR) << c; + err.assign("Could not create file.\n"); + FILE_LOG(logERROR) << err; return FAIL; } } else @@ -1417,7 +1406,7 @@ int slsReceiverImplementation::restreamStop() { /***callback functions***/ 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; pStartAcquisition = arg; } @@ -1537,9 +1526,9 @@ void slsReceiverImplementation::ResetParametersforNewAcquisition() { it->ResetParametersforNewAcquisition(); if (dataStreamEnable) { - char fnametostream[MAX_STR_LENGTH * 2]; - snprintf(fnametostream, MAX_STR_LENGTH * 2, "%s/%s", filePath, - fileName); + std::ostringstream os; + os << filePath << '/' << fileName; + std::string fnametostream = os.str(); for (const auto &it : dataStreamer) it->ResetParametersforNewAcquisition(fnametostream); } diff --git a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp index 5401268b8..d296b5c4f 100755 --- a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp +++ b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp @@ -69,7 +69,7 @@ int64_t slsReceiverTCPIPInterface::getReceiverVersion() { return APIRECEIVER; } /***callback functions***/ 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; pStartAcquisition = arg; } @@ -112,6 +112,7 @@ void slsReceiverTCPIPInterface::startTCPServer() { ret = decode_function(socket); } catch (const RuntimeError &e) { // We had an error needs to be sent to client + char mess[MAX_STR_LENGTH]{}; sls::strcpy_safe(mess, e.what()); socket.Send(FAIL); socket.Send(mess); @@ -274,9 +275,10 @@ void slsReceiverTCPIPInterface::VerifyLock() { void slsReceiverTCPIPInterface::VerifyIdle(Interface &socket) { if (impl()->getStatus() != IDLE) { - // sprintf(mess, "Can not execute %s when receiver is not idle\n", - // getFunctionNameFromEnum((enum detFuncs)fnum)); - throw sls::SocketError(mess); + std::ostringstream oss; + oss << "Can not execute " << getFunctionNameFromEnum((enum detFuncs)fnum) + << " 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) { if (impl()->getStatus() == IDLE) { FILE_LOG(logDEBUG1) << "Starting Receiver"; - ret = impl()->startReceiver(mess); + std::string err; + ret = impl()->startReceiver(err); if (ret == FAIL) { - throw RuntimeError(mess); + throw RuntimeError(err); } } return socket.Send(OK); @@ -852,8 +855,6 @@ int slsReceiverTCPIPInterface::set_streaming_timer(Interface &socket) { } int slsReceiverTCPIPInterface::set_flipped_data(Interface &socket) { - // TODO! Why 2 args? - memset(mess, 0, sizeof(mess)); auto arg = socket.Receive(); if (myDetectorType != EIGER) @@ -983,7 +984,6 @@ int slsReceiverTCPIPInterface::restream_stop(Interface &socket) { } int slsReceiverTCPIPInterface::set_additional_json_header(Interface &socket) { - memset(mess, 0, sizeof(mess)); char arg[MAX_STR_LENGTH]{}; char retval[MAX_STR_LENGTH]{}; socket.Receive(arg); diff --git a/slsReceiverSoftware/src/slsReceiverUsers.cpp b/slsReceiverSoftware/src/slsReceiverUsers.cpp index 3ce3c00f1..d0d4ba1fd 100755 --- a/slsReceiverSoftware/src/slsReceiverUsers.cpp +++ b/slsReceiverSoftware/src/slsReceiverUsers.cpp @@ -28,7 +28,7 @@ int64_t slsReceiverUsers::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); } diff --git a/slsSupportLib/include/ZmqSocket.h b/slsSupportLib/include/ZmqSocket.h index 9506a1804..2e2f23d26 100755 --- a/slsSupportLib/include/ZmqSocket.h +++ b/slsSupportLib/include/ZmqSocket.h @@ -278,7 +278,7 @@ public: uint32_t debug = 0, uint16_t roundRNumber = 0, uint8_t detType = 0, uint8_t version = 0, int gapPixelsEnable = 0, int flippedDataX = 0, uint32_t quadEnable = 0, - char* additionalJsonHeader = 0) { + std::string* additionalJsonHeader = 0) { @@ -331,9 +331,9 @@ public: quadEnable ); - if (additionalJsonHeader && strlen(additionalJsonHeader)) { + if (additionalJsonHeader && !((*additionalJsonHeader).empty())) { strcat(buf, ", "); - strcat(buf, additionalJsonHeader); + strcat(buf, (*additionalJsonHeader).c_str()); } strcat(buf, "}\n"); int length = strlen(buf);