From a351fa8f28722760eb98e2eb818f0960c9b48f6f Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Tue, 28 Nov 2017 11:18:30 +0100 Subject: [PATCH] switching from black to white background for receiver --- .../include/BinaryFileStatic.h | 6 ++-- slsReceiverSoftware/include/File.h | 14 ++++---- slsReceiverSoftware/include/GeneralData.h | 4 +-- slsReceiverSoftware/include/HDF5FileStatic.h | 30 ++++++++--------- slsReceiverSoftware/include/genericSocket.h | 6 ++-- slsReceiverSoftware/include/logger.h | 7 ++-- slsReceiverSoftware/src/BinaryFile.cpp | 2 +- slsReceiverSoftware/src/DataProcessor.cpp | 14 ++++---- slsReceiverSoftware/src/DataStreamer.cpp | 22 ++++++------- slsReceiverSoftware/src/Fifo.cpp | 4 +-- slsReceiverSoftware/src/HDF5File.cpp | 4 +-- slsReceiverSoftware/src/Listener.cpp | 20 ++++++------ slsReceiverSoftware/src/ThreadObject.cpp | 4 +-- .../src/UDPStandardImplementation.cpp | 32 +++++++++---------- slsReceiverSoftware/src/main.cpp | 14 ++++---- .../src/slsReceiverTCPIPInterface.cpp | 10 +++--- slsReceiverSoftware/src/utilities.cpp | 4 +-- 17 files changed, 98 insertions(+), 99 deletions(-) diff --git a/slsReceiverSoftware/include/BinaryFileStatic.h b/slsReceiverSoftware/include/BinaryFileStatic.h index 022f1e829..fda193213 100644 --- a/slsReceiverSoftware/include/BinaryFileStatic.h +++ b/slsReceiverSoftware/include/BinaryFileStatic.h @@ -118,12 +118,12 @@ class BinaryFileStatic { { if(!owenable){ if (NULL == (fd = fopen((const char *) fname.c_str(), "wx"))){ - bprintf(RED,"Error in creating binary master file %s\n",fname.c_str()); + cprintf(RED,"Error in creating binary master file %s\n",fname.c_str()); fd = 0; return 1; } }else if (NULL == (fd = fopen((const char *) fname.c_str(), "w"))){ - bprintf(RED,"Error in creating binary master file %s\n",fname.c_str()); + cprintf(RED,"Error in creating binary master file %s\n",fname.c_str()); fd = 0; return 1; } @@ -169,7 +169,7 @@ class BinaryFileStatic { (long long int)acquisitionPeriod, ctime(&t)); if (strlen(message) > MAX_STR_LENGTH) { - bprintf(RED,"Master File Size %d is greater than max str size %d\n", + cprintf(RED,"Master File Size %d is greater than max str size %d\n", (int)strlen(message), MAX_STR_LENGTH); return 1; } diff --git a/slsReceiverSoftware/include/File.h b/slsReceiverSoftware/include/File.h index bbc53d5e2..3e0abb406 100644 --- a/slsReceiverSoftware/include/File.h +++ b/slsReceiverSoftware/include/File.h @@ -100,7 +100,7 @@ class File : private virtual slsReceiverDefs { * @returns OK or FAIL */ virtual int CreateFile(uint64_t fnum){ - bprintf(RED,"This is a generic function CreateFile that should be overloaded by a derived class\n"); + cprintf(RED,"This is a generic function CreateFile that should be overloaded by a derived class\n"); return OK; } @@ -108,14 +108,14 @@ class File : private virtual slsReceiverDefs { * Close Current File */ virtual void CloseCurrentFile() { - bprintf(RED,"This is a generic function CloseCurrentFile that should be overloaded by a derived class\n"); + cprintf(RED,"This is a generic function CloseCurrentFile that should be overloaded by a derived class\n"); } /** * Close Files */ virtual void CloseAllFiles() { - bprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); + cprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); } /** @@ -126,7 +126,7 @@ class File : private virtual slsReceiverDefs { * @param OK or FAIL */ virtual int WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) { - bprintf(RED,"This is a generic function WriteToFile that should be overloaded by a derived class\n"); + cprintf(RED,"This is a generic function WriteToFile that should be overloaded by a derived class\n"); return FAIL; } @@ -143,7 +143,7 @@ class File : private virtual slsReceiverDefs { */ virtual int CreateMasterFile(bool en, uint32_t size, uint32_t nx, uint32_t ny, uint64_t at, uint64_t st, uint64_t ap) { - bprintf(RED,"This is a generic function CreateMasterFile that should be overloaded by a derived class\n"); + cprintf(RED,"This is a generic function CreateMasterFile that should be overloaded by a derived class\n"); return OK; } @@ -154,7 +154,7 @@ class File : private virtual slsReceiverDefs { * @param ny number of pixels in y direction */ virtual void SetNumberofPixels(uint32_t nx, uint32_t ny) { - bprintf(RED,"This is a generic function SetNumberofPixels that should be overloaded by a derived class\n"); + cprintf(RED,"This is a generic function SetNumberofPixels that should be overloaded by a derived class\n"); } /** @@ -162,7 +162,7 @@ class File : private virtual slsReceiverDefs { * @param numf number of images caught */ virtual void EndofAcquisition(uint64_t numf) { - bprintf(RED,"This is a generic function EndofAcquisition that should be overloaded by a derived class\n"); + cprintf(RED,"This is a generic function EndofAcquisition that should be overloaded by a derived class\n"); } protected: diff --git a/slsReceiverSoftware/include/GeneralData.h b/slsReceiverSoftware/include/GeneralData.h index 4b4fd3f31..9b6f4fbf7 100644 --- a/slsReceiverSoftware/include/GeneralData.h +++ b/slsReceiverSoftware/include/GeneralData.h @@ -151,7 +151,7 @@ public: * @param tgEnable true if 10GbE is enabled, else false */ virtual void SetDynamicRange(int dr, bool tgEnable) { - bprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); + cprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); }; /** @@ -160,7 +160,7 @@ public: * @param dr dynamic range */ virtual void SetTenGigaEnable(bool tgEnable, int dr) { - bprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); + cprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); }; /** diff --git a/slsReceiverSoftware/include/HDF5FileStatic.h b/slsReceiverSoftware/include/HDF5FileStatic.h index e8dbe2ba1..d66c776bf 100644 --- a/slsReceiverSoftware/include/HDF5FileStatic.h +++ b/slsReceiverSoftware/include/HDF5FileStatic.h @@ -111,7 +111,7 @@ public: fd = 0; } } catch(Exception error) { - bprintf(RED,"Error in closing HDF5 handles of index %d\n", ind); + cprintf(RED,"Error in closing HDF5 handles of index %d\n", ind); error.printError(); } } @@ -129,7 +129,7 @@ public: fd = 0; } } catch(Exception error) { - bprintf(RED,"Error in closing master HDF5 handles\n"); + cprintf(RED,"Error in closing master HDF5 handles\n"); error.printError(); } } @@ -143,7 +143,7 @@ public: { if(fd) { if (H5Fclose(fd) < 0 ) - bprintf(RED,"Error in closing virtual HDF5 handles\n"); + cprintf(RED,"Error in closing virtual HDF5 handles\n"); fd = 0; } } @@ -176,7 +176,7 @@ public: memspace.close(); } catch(Exception error){ - bprintf(RED,"Error in writing to file in object %d\n",ind); + cprintf(RED,"Error in writing to file in object %d\n",ind); error.printError(); return 1; } @@ -212,7 +212,7 @@ public: dset_para[12]->write(&header->version, ParameterDataTypes[12], memspace, *dspace_para); } catch(Exception error){ - bprintf(RED,"Error in writing parameters to file in object %d\n",ind); + cprintf(RED,"Error in writing parameters to file in object %d\n",ind); error.printError(); return 1; } @@ -327,7 +327,7 @@ public: fd->close(); } catch(Exception error) { - bprintf(RED,"Error in creating master HDF5 handles\n"); + cprintf(RED,"Error in creating master HDF5 handles\n"); error.printError(); return 1; } @@ -411,7 +411,7 @@ public: dset_para[i] = new DataSet(fd->createDataSet(ParameterNames[i], ParameterDataTypes[i], *dspace_para)); } catch(Exception error){ - bprintf(RED,"Error in creating HDF5 handles in object %d\n",ind); + cprintf(RED,"Error in creating HDF5 handles in object %d\n",ind); error.printError(); fd->close(); return 1; @@ -527,12 +527,12 @@ public: //setect hyperslabs if (H5Sselect_hyperslab (vdsDataspace, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) { - bprintf(RED,"could not select hyperslab\n"); + cprintf(RED,"could not select hyperslab\n"); error = true; break; } if (H5Sselect_hyperslab (vdsDataspace_para, H5S_SELECT_SET, offset_para, NULL, count_para, NULL) < 0) { - bprintf(RED,"could not select hyperslab for parameters\n"); + cprintf(RED,"could not select hyperslab for parameters\n"); error = true; break; } @@ -559,14 +559,14 @@ public: //mapping if (H5Pset_virtual(dcpl, vdsDataspace, srcFileName.c_str(), srcDatasetName.c_str(), srcDataspace) < 0) { - bprintf(RED,"could not set mapping for paramter 1\n"); + cprintf(RED,"could not set mapping for paramter 1\n"); error = true; break; } for (int k = 0; k < NumberofParameters; ++k) { if (H5Pset_virtual(dcpl_para[k], vdsDataspace_para, srcFileName.c_str(), ParameterNames[k], srcDataspace_para) < 0) { - bprintf(RED,"could not set mapping for paramter %d\n", k); + cprintf(RED,"could not set mapping for paramter %d\n", k); error = true; break; } @@ -639,7 +639,7 @@ public: data_out = (T*)malloc(sizeof(T)*(nDimx*nDimy*nDimz)); break; default: - bprintf(RED,"invalid rank. Options: 2 or 3\n"); + cprintf(RED,"invalid rank. Options: 2 or 3\n"); return 0; } if (datatype == PredType::STD_U16LE) { @@ -696,7 +696,7 @@ public: newfd->close(); oldfd->close(); } catch(Exception error){ - bprintf(RED,"Error in copying virtual files\n"); + cprintf(RED,"Error in copying virtual files\n"); error.printError(); free(data_out); oldfd->close(); @@ -780,7 +780,7 @@ public: * @returns 1 for fail */ static int CloseFileOnError(hid_t& fd, const string msg) { - bprintf(RED, "%s", msg.c_str()); + cprintf(RED, "%s", msg.c_str()); if(fd > 0) H5Fclose(fd); fd = 0; @@ -803,7 +803,7 @@ public: else if (dtype == PredType::STD_U64LE) return H5T_STD_U64LE; else { - bprintf(RED, "Invalid Data type\n"); + cprintf(RED, "Invalid Data type\n"); return H5T_STD_U64LE; } } diff --git a/slsReceiverSoftware/include/genericSocket.h b/slsReceiverSoftware/include/genericSocket.h index 5d2a0454a..8ca367989 100644 --- a/slsReceiverSoftware/include/genericSocket.h +++ b/slsReceiverSoftware/include/genericSocket.h @@ -659,7 +659,7 @@ enum communicationProtocol{ continue; if(nsent != nsending){ if(nsent && (nsent != -1)) - bprintf(RED,"Incomplete Packet size %d\n",nsent); + cprintf(RED,"Incomplete Packet size %d\n",nsent); break; } length-=nsent; @@ -672,7 +672,7 @@ enum communicationProtocol{ nsending=packet_size; while(1){ #ifdef VERYVERBOSE - bprintf(BLUE,"%d gonna listen\n", portno); fflush(stdout); + cprintf(BLUE,"%d gonna listen\n", portno); fflush(stdout); #endif nsent = recvfrom(socketDescriptor,(char*)buf+total_sent,nsending, 0, (struct sockaddr *) &clientAddress, &clientAddress_length); //break out of loop only if read one packets size or read didnt work (cuz of shutdown) @@ -680,7 +680,7 @@ enum communicationProtocol{ break; //incomplete packets or header packets ignored and read buffer again if(nsent != packet_size && nsent != header_packet_size) - bprintf(RED,"%d Incomplete Packet size %d\n", portno, nsent); + cprintf(RED,"%d Incomplete Packet size %d\n", portno, nsent); } //nsent = 1040; if(nsent > 0)total_sent+=nsent; diff --git a/slsReceiverSoftware/include/logger.h b/slsReceiverSoftware/include/logger.h index 8331a19e6..562b7e860 100644 --- a/slsReceiverSoftware/include/logger.h +++ b/slsReceiverSoftware/include/logger.h @@ -218,10 +218,9 @@ inline void Output2FILE::Output(const std::string& msg, TLogLevel level) return; bool out = true; switch(level){ - case logERROR: bprintf(RED BOLD,"%s",msg.c_str()); break; - case logWARNING: bprintf(YELLOW BOLD,"%s",msg.c_str()); break; - case logINFO: bprintf(GRAY,"%s",msg.c_str()); break; - // case logINFO: bprintf(DARKGRAY BOLD,"%s",msg.c_str());break; + case logERROR: cprintf(RED BOLD,"%s",msg.c_str()); break; + case logWARNING: cprintf(YELLOW BOLD,"%s",msg.c_str()); break; + case logINFO: cprintf(DARKGRAY,"%s",msg.c_str()); break; default: fprintf(pStream,"%s",msg.c_str()); out = false; break; } fflush(out ? stdout : pStream); diff --git a/slsReceiverSoftware/src/BinaryFile.cpp b/slsReceiverSoftware/src/BinaryFile.cpp index 5d459ac10..91cd968f8 100644 --- a/slsReceiverSoftware/src/BinaryFile.cpp +++ b/slsReceiverSoftware/src/BinaryFile.cpp @@ -80,7 +80,7 @@ int BinaryFile::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_ numActualPacketsInFile += nump; if (BinaryFileStatic::WriteDataFile(filefd, buffer, buffersize, fnum) == buffersize) return OK; - bprintf(RED,"%d Error: Write to file failed for image number %lld\n", index, (long long int)fnum); + cprintf(RED,"%d Error: Write to file failed for image number %lld\n", index, (long long int)fnum); return FAIL; } diff --git a/slsReceiverSoftware/src/DataProcessor.cpp b/slsReceiverSoftware/src/DataProcessor.cpp index edb4a645d..74c382f9d 100644 --- a/slsReceiverSoftware/src/DataProcessor.cpp +++ b/slsReceiverSoftware/src/DataProcessor.cpp @@ -183,7 +183,7 @@ void DataProcessor::RecordFirstIndices(uint64_t fnum) { } #ifdef VERBOSE - bprintf(BLUE,"%d First Acquisition Index:%lld\tFirst Measurement Index:%lld\n", + cprintf(BLUE,"%d First Acquisition Index:%lld\tFirst Measurement Index:%lld\n", index, (long long int)firstAcquisitionIndex, (long long int)firstMeasurementIndex); #endif } @@ -293,13 +293,13 @@ void DataProcessor::ThreadExecution() { char* buffer=0; fifo->PopAddress(buffer); #ifdef FIFODEBUG - if (!index) bprintf(BLUE,"DataProcessor %d, pop 0x%p buffer:%s\n", index,(void*)(buffer),buffer); + if (!index) cprintf(BLUE,"DataProcessor %d, pop 0x%p buffer:%s\n", index,(void*)(buffer),buffer); #endif //check dummy uint32_t numBytes = (uint32_t)(*((uint32_t*)buffer)); #ifdef VERBOSE - if (!index) bprintf(BLUE,"DataProcessor %d, Numbytes:%u\n", index,numBytes); + if (!index) cprintf(BLUE,"DataProcessor %d, Numbytes:%u\n", index,numBytes); #endif if (numBytes == DUMMY_PACKET_VALUE) { StopProcessing(buffer); @@ -319,7 +319,7 @@ void DataProcessor::ThreadExecution() { void DataProcessor::StopProcessing(char* buf) { #ifdef VERBOSE if (!index) - bprintf(RED,"DataProcessing %d: Dummy\n", index); + cprintf(RED,"DataProcessing %d: Dummy\n", index); #endif //stream or free if (*dataStreamEnable) @@ -350,12 +350,12 @@ void DataProcessor::ProcessAnImage(char* buf) { #ifdef VERBOSE if (!index) - bprintf(BLUE,"DataProcessing %d: fnum:%lu\n", index, fnum); + cprintf(BLUE,"DataProcessing %d: fnum:%lu\n", index, fnum); #endif if (!measurementStartedFlag) { #ifdef VERBOSE - if (!index) bprintf(BLUE,"DataProcessing %d: fnum:%lu\n", index, fnum); + if (!index) cprintf(BLUE,"DataProcessing %d: fnum:%lu\n", index, fnum); #endif RecordFirstIndices(fnum); @@ -418,7 +418,7 @@ bool DataProcessor::CheckTimer() { struct timespec end; clock_gettime(CLOCK_REALTIME, &end); #ifdef VERBOSE - bprintf(BLUE,"%d Timer elapsed time:%f seconds\n", index, ( end.tv_sec - timerBegin.tv_sec ) + ( end.tv_nsec - timerBegin.tv_nsec ) / 1000000000.0); + cprintf(BLUE,"%d Timer elapsed time:%f seconds\n", index, ( end.tv_sec - timerBegin.tv_sec ) + ( end.tv_nsec - timerBegin.tv_nsec ) / 1000000000.0); #endif //still less than streaming timer, keep waiting if((( end.tv_sec - timerBegin.tv_sec ) + ( end.tv_nsec - timerBegin.tv_nsec ) / 1000000000.0) < ((double)*streamingTimerInMs/1000.00)) diff --git a/slsReceiverSoftware/src/DataStreamer.cpp b/slsReceiverSoftware/src/DataStreamer.cpp index a041f4d7c..5c0fa0aaf 100644 --- a/slsReceiverSoftware/src/DataStreamer.cpp +++ b/slsReceiverSoftware/src/DataStreamer.cpp @@ -139,7 +139,7 @@ void DataStreamer::RecordFirstIndices(uint64_t fnum) { } #ifdef VERBOSE - bprintf(BLUE,"%d First Acquisition Index:%lld\tFirst Measurement Index:%lld\n", + cprintf(BLUE,"%d First Acquisition Index:%lld\tFirst Measurement Index:%lld\n", index, (long long int)firstAcquisitionIndex, (long long int)firstMeasurementIndex); #endif } @@ -167,7 +167,7 @@ int DataStreamer::CreateZmqSockets(int* nunits, uint32_t port) { zmqSocket = new ZmqSocket(portnum); if (zmqSocket->IsError()) { - bprintf(RED, "Error: Could not create Zmq socket on port %d for Streamer %d\n", portnum, index); + cprintf(RED, "Error: Could not create Zmq socket on port %d for Streamer %d\n", portnum, index); return FAIL; } FILE_LOG(logINFO) << index << " Streamer: Zmq Server started at " << zmqSocket->GetZmqServerAddress(); @@ -187,13 +187,13 @@ void DataStreamer::ThreadExecution() { char* buffer=0; fifo->PopAddressToStream(buffer); #ifdef FIFODEBUG - if (!index) bprintf(BLUE,"DataStreamer %d, pop 0x%p buffer:%s\n", index,(void*)(buffer),buffer); + if (!index) cprintf(BLUE,"DataStreamer %d, pop 0x%p buffer:%s\n", index,(void*)(buffer),buffer); #endif //check dummy uint32_t numBytes = (uint32_t)(*((uint32_t*)buffer)); #ifdef VERBOSE - bprintf(GREEN,"DataStreamer %d, Numbytes:%u\n", index,numBytes); + cprintf(GREEN,"DataStreamer %d, Numbytes:%u\n", index,numBytes); #endif if (numBytes == DUMMY_PACKET_VALUE) { StopProcessing(buffer); @@ -212,12 +212,12 @@ void DataStreamer::ThreadExecution() { void DataStreamer::StopProcessing(char* buf) { #ifdef VERBOSE if (!index) - bprintf(RED,"DataStreamer %d: Dummy\n", index); + cprintf(RED,"DataStreamer %d: Dummy\n", index); #endif sls_detector_header* header = (sls_detector_header*) (buf); //send dummy header and data if (!SendHeader(header, true)) - bprintf(RED,"Error: Could not send zmq dummy header for streamer %d\n", index); + cprintf(RED,"Error: Could not send zmq dummy header for streamer %d\n", index); fifo->FreeAddress(buf); StopRunning(); @@ -232,31 +232,31 @@ void DataStreamer::ProcessAnImage(char* buf) { sls_detector_header* header = (sls_detector_header*) (buf); uint64_t fnum = header->frameNumber; #ifdef VERBOSE - bprintf(MAGENTA,"DataStreamer %d: fnum:%lu\n", index,fnum); + cprintf(MAGENTA,"DataStreamer %d: fnum:%lu\n", index,fnum); #endif if (!measurementStartedFlag) { #ifdef VERBOSE - if (!index) bprintf(MAGENTA,"DataStreamer %d: fnum:%lu\n", index, fnum); + if (!index) cprintf(MAGENTA,"DataStreamer %d: fnum:%lu\n", index, fnum); #endif RecordFirstIndices(fnum); } if (!SendHeader(header)) - bprintf(RED,"Error: Could not send zmq header for fnum %lld and streamer %d\n", + cprintf(RED,"Error: Could not send zmq header for fnum %lld and streamer %d\n", (long long int) fnum, index); //shortframe gotthard - data sending if (completeBuffer) { memcpy(completeBuffer + ((generalData->imageSize)**shortFrameEnable), buf + sizeof(sls_detector_header), generalData->imageSize); if (!zmqSocket->SendData(completeBuffer, generalData->imageSize_Streamer)) - bprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n", + cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n", (long long int) fnum, index); } //normal - data sending else { if (!zmqSocket->SendData(buf + sizeof(sls_detector_header), generalData->imageSize)) - bprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n", + cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n", (long long int) fnum, index); } } diff --git a/slsReceiverSoftware/src/Fifo.cpp b/slsReceiverSoftware/src/Fifo.cpp index a51a650c4..f545235b6 100644 --- a/slsReceiverSoftware/src/Fifo.cpp +++ b/slsReceiverSoftware/src/Fifo.cpp @@ -32,7 +32,7 @@ Fifo::Fifo(uint32_t fifoItemSize, uint32_t depth, bool &success): Fifo::~Fifo() { FILE_LOG (logDEBUG) << __AT__ << " called"; - //bprintf(BLUE,"Fifo Object %d: Goodbye\n", index); + //cprintf(BLUE,"Fifo Object %d: Goodbye\n", index); DestroyFifos(); NumberofFifoClassObjects--; } @@ -64,7 +64,7 @@ int Fifo::CreateFifos(uint32_t fifoItemSize) { while (buffer < (memory + fifoItemSize * (fifoDepth-1))) { //sprintf(buffer,"memory"); #ifdef FIFODEBUG - bprintf(MAGENTA,"Fifofree %d: value:%d, pop 0x%p\n", index, fifoFree->getSemValue(), (void*)(buffer)); + cprintf(MAGENTA,"Fifofree %d: value:%d, pop 0x%p\n", index, fifoFree->getSemValue(), (void*)(buffer)); #endif FreeAddress(buffer); buffer += fifoItemSize; diff --git a/slsReceiverSoftware/src/HDF5File.cpp b/slsReceiverSoftware/src/HDF5File.cpp index a52cb18eb..3635f26b9 100644 --- a/slsReceiverSoftware/src/HDF5File.cpp +++ b/slsReceiverSoftware/src/HDF5File.cpp @@ -109,7 +109,7 @@ int HDF5File::CreateFile(uint64_t fnum) { } pthread_mutex_unlock(&Mutex); if (dataspace == NULL) - bprintf(RED,"Got nothing!\n"); + cprintf(RED,"Got nothing!\n"); if(!silentMode) FILE_LOG(logINFO) << *udpPortNumber << ": HDF5 File created: " << currentFileName; @@ -158,7 +158,7 @@ int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t } } pthread_mutex_unlock(&Mutex); - bprintf(RED,"%d Error: Write to file failed\n", index); + cprintf(RED,"%d Error: Write to file failed\n", index); return FAIL; } diff --git a/slsReceiverSoftware/src/Listener.cpp b/slsReceiverSoftware/src/Listener.cpp index f3a4cb84d..1b147795a 100644 --- a/slsReceiverSoftware/src/Listener.cpp +++ b/slsReceiverSoftware/src/Listener.cpp @@ -190,7 +190,7 @@ void Listener::RecordFirstIndices(uint64_t fnum) { } if(!SilentMode) { - if (!index) bprintf(BLUE,"%d First Acquisition Index:%lu\n" + if (!index) cprintf(BLUE,"%d First Acquisition Index:%lu\n" "%d First Measurement Index:%lu\n", index, firstAcquisitionIndex, index, firstMeasurementIndex); @@ -262,7 +262,7 @@ void Listener::ThreadExecution() { fifo->GetNewAddress(buffer); #ifdef FIFODEBUG - bprintf(GREEN,"Listener %d, pop 0x%p buffer:%s\n", index,(void*)(buffer),buffer); + cprintf(GREEN,"Listener %d, pop 0x%p buffer:%s\n", index,(void*)(buffer),buffer); #endif //udpsocket doesnt exist @@ -325,8 +325,8 @@ void Listener::StopListening(char* buf) { udpSocket = 0; } #ifdef VERBOSE - bprintf(GREEN,"%d: Listening Packets (%u) : %llu\n", index, *udpPortNumber, numPacketsCaught); - bprintf(GREEN,"%d: Listening Completed\n", index); + cprintf(GREEN,"%d: Listening Packets (%u) : %llu\n", index, *udpPortNumber, numPacketsCaught); + cprintf(GREEN,"%d: Listening Completed\n", index); #endif } @@ -355,7 +355,7 @@ uint32_t Listener::ListenToAnImage(char* buf) { //look for carry over if (carryOverFlag) { - //bprintf(RED,"%d carry flag\n",index); + //cprintf(RED,"%d carry flag\n",index); //check if its the current image packet // -------------------------- new header ---------------------------------------------------------------------- if (standardheader) { @@ -371,7 +371,7 @@ uint32_t Listener::ListenToAnImage(char* buf) { //------------------------------------------------------------------------------------------------------------ if (fnum != currentFrameIndex) { if (fnum < currentFrameIndex) { - bprintf(RED,"Error:(Weird), With carry flag: Frame number %lu less than current frame number %lu\n", fnum, currentFrameIndex); + cprintf(RED,"Error:(Weird), With carry flag: Frame number %lu less than current frame number %lu\n", fnum, currentFrameIndex); return 0; } new_header->packetNumber = numpackets; @@ -463,7 +463,7 @@ uint32_t Listener::ListenToAnImage(char* buf) { #ifdef VERBOSE //if (!index) - bprintf(GREEN,"Listening %d: currentfindex:%lu, fnum:%lu, pnum:%u numpackets:%u\n", + cprintf(GREEN,"Listening %d: currentfindex:%lu, fnum:%lu, pnum:%u numpackets:%u\n", index,currentFrameIndex, fnum, pnum, numpackets); #endif if (!measurementStartedFlag) @@ -471,7 +471,7 @@ uint32_t Listener::ListenToAnImage(char* buf) { //future packet by looking at image number (all other detectors) if (fnum != currentFrameIndex) { - //bprintf(RED,"setting carry over flag to true num:%llu nump:%u\n",fnum, numpackets ); + //cprintf(RED,"setting carry over flag to true num:%llu nump:%u\n",fnum, numpackets ); carryOverFlag = true; memcpy(carryOverPacket,listeningPacket, generalData->packetSize); @@ -547,9 +547,9 @@ void Listener::PrintFifoStatistics() { numFramesStatistic = 0; if (loss) - bprintf(RED,"[%u]: Packet_Loss:%lu Used_Fifo_Max_Level:%d \tFree_Slots_Min_Level:%d \tCurrent_Frame#:%lu\n", + cprintf(RED,"[%u]: Packet_Loss:%lu Used_Fifo_Max_Level:%d \tFree_Slots_Min_Level:%d \tCurrent_Frame#:%lu\n", *udpPortNumber,loss, fifo->GetMaxLevelForFifoBound() , fifo->GetMinLevelForFifoFree(), currentFrameIndex); else - bprintf(GREEN,"[%u]: Packet_Loss:%lu Used_Fifo_Max_Level:%d \tFree_Slots_Min_Level:%d \tCurrent_Frame#:%lu\n", + cprintf(GREEN,"[%u]: Packet_Loss:%lu Used_Fifo_Max_Level:%d \tFree_Slots_Min_Level:%d \tCurrent_Frame#:%lu\n", *udpPortNumber,loss, fifo->GetMaxLevelForFifoBound(), fifo->GetMinLevelForFifoFree(), currentFrameIndex); } diff --git a/slsReceiverSoftware/src/ThreadObject.cpp b/slsReceiverSoftware/src/ThreadObject.cpp index e59b3f6b7..f17bed83a 100644 --- a/slsReceiverSoftware/src/ThreadObject.cpp +++ b/slsReceiverSoftware/src/ThreadObject.cpp @@ -75,7 +75,7 @@ void* ThreadObject::StartThread(void* thisPointer) { void ThreadObject::RunningThread() { - bprintf(BLUE,"Created [ %s Thread %d, Tid: %ld ]\n", GetType().c_str(),index, (long)syscall(SYS_gettid)); + cprintf(BLUE,"Created [ %s Thread %d, Tid: %ld ]\n", GetType().c_str(),index, (long)syscall(SYS_gettid)); while(true) { while(IsRunning()) { @@ -89,7 +89,7 @@ void ThreadObject::RunningThread() { sem_wait(&semaphore); if(killThread) { - bprintf(BLUE,"Exiting [ %s Thread %d, Tid: %ld ]\n", GetType().c_str(),index, (long)syscall(SYS_gettid)); + cprintf(BLUE,"Exiting [ %s Thread %d, Tid: %ld ]\n", GetType().c_str(),index, (long)syscall(SYS_gettid)); pthread_exit(NULL); } diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp index e5d434099..3d49d7edc 100644 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ b/slsReceiverSoftware/src/UDPStandardImplementation.cpp @@ -147,7 +147,7 @@ void UDPStandardImplementation::setFileWriteEnable(const bool b){ int UDPStandardImplementation::setShortFrameEnable(const int i) { if (myDetectorType != GOTTHARD) { - bprintf(RED, "Error: Can not set short frame for this detector\n"); + cprintf(RED, "Error: Can not set short frame for this detector\n"); return FAIL; } @@ -218,9 +218,9 @@ int UDPStandardImplementation::setDataStreamEnable(const bool enable) { } if (DataStreamer::GetErrorMask() || error) { if (DataStreamer::GetErrorMask()) - bprintf(RED,"Error: Could not create data callback threads\n"); + cprintf(RED,"Error: Could not create data callback threads\n"); else - bprintf(RED,"Error: Could not create zmq sockets\n"); + cprintf(RED,"Error: Could not create zmq sockets\n"); for (vector::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) delete(*it); dataStreamer.clear(); @@ -393,7 +393,7 @@ void UDPStandardImplementation::resetAcquisitionCount() { int UDPStandardImplementation::startReceiver(char *c) { - bprintf(GRAY,"\n"); + cprintf(DARKGRAY,"\n"); FILE_LOG(logINFO) << "Starting Receiver"; ResetParametersforNewMeasurement(); @@ -481,19 +481,19 @@ void UDPStandardImplementation::stopReceiver(){ uint64_t missingpackets = numberOfFrames*generalData->packetsPerFrame-listener[i]->GetPacketsCaught(); if (missingpackets) { - bprintf(RED, "\n[Port %d]\n",udpPortNum[i]); - bprintf(RED, "Missing Packets\t\t: %lld\n",(long long int)missingpackets); - bprintf(RED, "Complete Frames\t\t: %lld\n",(long long int)dataProcessor[i]->GetNumFramesCaught()); - bprintf(RED, "Last Frame Caught\t: %lld\n",(long long int)listener[i]->GetLastFrameIndexCaught()); + cprintf(RED, "\n[Port %d]\n",udpPortNum[i]); + cprintf(RED, "Missing Packets\t\t: %lld\n",(long long int)missingpackets); + cprintf(RED, "Complete Frames\t\t: %lld\n",(long long int)dataProcessor[i]->GetNumFramesCaught()); + cprintf(RED, "Last Frame Caught\t: %lld\n",(long long int)listener[i]->GetLastFrameIndexCaught()); }else{ - bprintf(GREEN, "\n[Port %d]\n",udpPortNum[i]); - bprintf(GREEN, "Missing Packets\t\t: %lld\n",(long long int)missingpackets); - bprintf(GREEN, "Complete Frames\t\t: %lld\n",(long long int)dataProcessor[i]->GetNumFramesCaught()); - bprintf(GREEN, "Last Frame Caught\t: %lld\n",(long long int)listener[i]->GetLastFrameIndexCaught()); + cprintf(GREEN, "\n[Port %d]\n",udpPortNum[i]); + cprintf(GREEN, "Missing Packets\t\t: %lld\n",(long long int)missingpackets); + cprintf(GREEN, "Complete Frames\t\t: %lld\n",(long long int)dataProcessor[i]->GetNumFramesCaught()); + cprintf(GREEN, "Last Frame Caught\t: %lld\n",(long long int)listener[i]->GetLastFrameIndexCaught()); } } if(!activated) - bprintf(RED,"Note: Deactivated Receiver\n"); + cprintf(RED,"Note: Deactivated Receiver\n"); //callback if (acquisitionFinishedCallBack) acquisitionFinishedCallBack((tot/numThreads), pAcquisitionFinished); @@ -525,7 +525,7 @@ void UDPStandardImplementation::startReadout(){ //wait as long as there is change from prev totalP, while(prev != totalP){ #ifdef VERY_VERBOSE - bprintf(MAGENTA,"waiting for all packets prevP:%d totalP:%d\n", + cprintf(MAGENTA,"waiting for all packets prevP:%d totalP:%d\n", prev,totalP); #endif @@ -538,7 +538,7 @@ void UDPStandardImplementation::startReadout(){ for (vector::const_iterator it = listener.begin(); it != listener.end(); ++it) totalP += (*it)->GetPacketsCaught(); #ifdef VERY_VERBOSE - bprintf(MAGENTA,"\tupdated: totalP:%d\n",totalP); + cprintf(MAGENTA,"\tupdated: totalP:%d\n",totalP); #endif } } @@ -629,7 +629,7 @@ int UDPStandardImplementation::SetupFifoStructure() { (generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize), fifoDepth, success)); if (!success) { - bprintf(RED,"Error: Could not allocate memory for fifo structure of index %d\n", i); + cprintf(RED,"Error: Could not allocate memory for fifo structure of index %d\n", i); for (vector::const_iterator it = fifo.begin(); it != fifo.end(); ++it) delete(*it); fifo.clear(); diff --git a/slsReceiverSoftware/src/main.cpp b/slsReceiverSoftware/src/main.cpp index 19c98f58d..f791418ab 100644 --- a/slsReceiverSoftware/src/main.cpp +++ b/slsReceiverSoftware/src/main.cpp @@ -60,7 +60,7 @@ void GetData(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, ui int main(int argc, char *argv[]) { keeprunning = true; - bprintf(BLUE,"Created [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); + cprintf(BLUE,"Created [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); // Catch signal SIGINT to close files and call destructors properly struct sigaction sa; @@ -68,7 +68,7 @@ int main(int argc, char *argv[]) { sa.sa_handler=sigInterruptHandler; // handler function sigemptyset(&sa.sa_mask); // dont block additional signals during invocation of handler if (sigaction(SIGINT, &sa, NULL) == -1) { - bprintf(RED, "Could not set handler function for SIGINT\n"); + cprintf(RED, "Could not set handler function for SIGINT\n"); } @@ -79,7 +79,7 @@ int main(int argc, char *argv[]) { asa.sa_handler=SIG_IGN; // handler function sigemptyset(&asa.sa_mask); // dont block additional signals during invocation of handler if (sigaction(SIGPIPE, &asa, NULL) == -1) { - bprintf(RED, "Could not set handler function for SIGPIPE\n"); + cprintf(RED, "Could not set handler function for SIGPIPE\n"); } @@ -87,7 +87,7 @@ int main(int argc, char *argv[]) { slsReceiverUsers *receiver = new slsReceiverUsers(argc, argv, ret); if(ret==slsReceiverDefs::FAIL){ delete receiver; - bprintf(BLUE,"Exiting [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); + cprintf(BLUE,"Exiting [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); exit(EXIT_FAILURE); } @@ -136,17 +136,17 @@ int main(int argc, char *argv[]) { //start tcp server thread if (receiver->start() == slsReceiverDefs::FAIL){ delete receiver; - bprintf(BLUE,"Exiting [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); + cprintf(BLUE,"Exiting [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); exit(EXIT_FAILURE); } FILE_LOG(logINFO) << "Ready ... "; - bprintf(GRAY, "\n[ Press \'Ctrl+c\' to exit ]\n"); + cprintf(DARKGRAY, "\n[ Press \'Ctrl+c\' to exit ]\n"); while(keeprunning) pause(); delete receiver; - bprintf(BLUE,"Exiting [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); + cprintf(BLUE,"Exiting [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); FILE_LOG(logINFO) << "Goodbye!"; return 0; } diff --git a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp index 43c63e25c..563a7540f 100644 --- a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp +++ b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp @@ -186,7 +186,7 @@ void* slsReceiverTCPIPInterface::startTCPServerThread(void *this_pointer){ void slsReceiverTCPIPInterface::startTCPServer(){ - bprintf(BLUE,"Created [ TCP server Tid: %ld ]\n", (long)syscall(SYS_gettid)); + cprintf(BLUE,"Created [ TCP server Tid: %ld ]\n", (long)syscall(SYS_gettid)); #ifdef VERYVERBOSE FILE_LOG(logDEBUG5) << "Starting Receiver TCP Server"; @@ -222,7 +222,7 @@ void slsReceiverTCPIPInterface::startTCPServer(){ } mySock->exitServer(); - bprintf(BLUE,"Exiting [ TCP server Tid: %ld ]\n", (long)syscall(SYS_gettid)); + cprintf(BLUE,"Exiting [ TCP server Tid: %ld ]\n", (long)syscall(SYS_gettid)); pthread_exit(NULL); } @@ -233,7 +233,7 @@ void slsReceiverTCPIPInterface::startTCPServer(){ receiverBase->shutDownUDPSockets(); } } - bprintf(BLUE,"Exiting [ TCP server Tid: %ld ]\n", (long)syscall(SYS_gettid)); + cprintf(BLUE,"Exiting [ TCP server Tid: %ld ]\n", (long)syscall(SYS_gettid)); pthread_exit(NULL); } @@ -345,7 +345,7 @@ int slsReceiverTCPIPInterface::function_table(){ int slsReceiverTCPIPInterface::decode_function(){ ret = FAIL; #ifdef VERYVERBOSE - bprintf(GRAY,"\n"); + cprintf(DARKGRAY,"\n"); FILE_LOG(logDEBUG1) << "waiting to receive data"; #endif int n = mySock->ReceiveDataOnly(&fnum,sizeof(fnum)); @@ -475,7 +475,7 @@ int slsReceiverTCPIPInterface::exit_server() { strcpy(mess,"closing server"); mySock->SendDataOnly(&ret,sizeof(ret)); mySock->SendDataOnly(mess,sizeof(mess)); - bprintf(RED,"%s\n",mess); + cprintf(RED,"%s\n",mess); return ret; } diff --git a/slsReceiverSoftware/src/utilities.cpp b/slsReceiverSoftware/src/utilities.cpp index e73e5a6c4..39079e7c1 100644 --- a/slsReceiverSoftware/src/utilities.cpp +++ b/slsReceiverSoftware/src/utilities.cpp @@ -54,9 +54,9 @@ int read_config_file(string fname, int *tcpip_port_no, map * con if(sstr.good()) { sstr >> sargname; if(sscanf(sargname.c_str(),"%d",tcpip_port_no)) - bprintf(GRAY, "dataport: %d\n" , *tcpip_port_no); + cprintf(DARKGRAY, "dataport: %d\n" , *tcpip_port_no); else{ - bprintf(RED, "could not decode port in config file. Exiting.\n"); + cprintf(RED, "could not decode port in config file. Exiting.\n"); success = slsReceiverDefs::FAIL; } }