switching from black to white background for receiver

This commit is contained in:
Dhanya Maliakal 2017-11-28 11:18:30 +01:00
parent eb89e9bf96
commit a351fa8f28
17 changed files with 98 additions and 99 deletions

View File

@ -118,12 +118,12 @@ class BinaryFileStatic {
{ {
if(!owenable){ if(!owenable){
if (NULL == (fd = fopen((const char *) fname.c_str(), "wx"))){ 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; fd = 0;
return 1; return 1;
} }
}else if (NULL == (fd = fopen((const char *) fname.c_str(), "w"))){ }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; fd = 0;
return 1; return 1;
} }
@ -169,7 +169,7 @@ class BinaryFileStatic {
(long long int)acquisitionPeriod, (long long int)acquisitionPeriod,
ctime(&t)); ctime(&t));
if (strlen(message) > MAX_STR_LENGTH) { 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); (int)strlen(message), MAX_STR_LENGTH);
return 1; return 1;
} }

View File

@ -100,7 +100,7 @@ class File : private virtual slsReceiverDefs {
* @returns OK or FAIL * @returns OK or FAIL
*/ */
virtual int CreateFile(uint64_t fnum){ 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; return OK;
} }
@ -108,14 +108,14 @@ class File : private virtual slsReceiverDefs {
* Close Current File * Close Current File
*/ */
virtual void CloseCurrentFile() { 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 * Close Files
*/ */
virtual void CloseAllFiles() { 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 * @param OK or FAIL
*/ */
virtual int WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) { 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; return FAIL;
} }
@ -143,7 +143,7 @@ class File : private virtual slsReceiverDefs {
*/ */
virtual int CreateMasterFile(bool en, uint32_t size, virtual int CreateMasterFile(bool en, uint32_t size,
uint32_t nx, uint32_t ny, uint64_t at, uint64_t st, uint64_t ap) { 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; return OK;
} }
@ -154,7 +154,7 @@ class File : private virtual slsReceiverDefs {
* @param ny number of pixels in y direction * @param ny number of pixels in y direction
*/ */
virtual void SetNumberofPixels(uint32_t nx, uint32_t ny) { 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 * @param numf number of images caught
*/ */
virtual void EndofAcquisition(uint64_t numf) { 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: protected:

View File

@ -151,7 +151,7 @@ public:
* @param tgEnable true if 10GbE is enabled, else false * @param tgEnable true if 10GbE is enabled, else false
*/ */
virtual void SetDynamicRange(int dr, bool tgEnable) { 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 * @param dr dynamic range
*/ */
virtual void SetTenGigaEnable(bool tgEnable, int dr) { 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");
}; };
/** /**

View File

@ -111,7 +111,7 @@ public:
fd = 0; fd = 0;
} }
} catch(Exception error) { } 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(); error.printError();
} }
} }
@ -129,7 +129,7 @@ public:
fd = 0; fd = 0;
} }
} catch(Exception error) { } catch(Exception error) {
bprintf(RED,"Error in closing master HDF5 handles\n"); cprintf(RED,"Error in closing master HDF5 handles\n");
error.printError(); error.printError();
} }
} }
@ -143,7 +143,7 @@ public:
{ {
if(fd) { if(fd) {
if (H5Fclose(fd) < 0 ) if (H5Fclose(fd) < 0 )
bprintf(RED,"Error in closing virtual HDF5 handles\n"); cprintf(RED,"Error in closing virtual HDF5 handles\n");
fd = 0; fd = 0;
} }
} }
@ -176,7 +176,7 @@ public:
memspace.close(); memspace.close();
} }
catch(Exception error){ 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(); error.printError();
return 1; return 1;
} }
@ -212,7 +212,7 @@ public:
dset_para[12]->write(&header->version, ParameterDataTypes[12], memspace, *dspace_para); dset_para[12]->write(&header->version, ParameterDataTypes[12], memspace, *dspace_para);
} }
catch(Exception error){ 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(); error.printError();
return 1; return 1;
} }
@ -327,7 +327,7 @@ public:
fd->close(); fd->close();
} catch(Exception error) { } catch(Exception error) {
bprintf(RED,"Error in creating master HDF5 handles\n"); cprintf(RED,"Error in creating master HDF5 handles\n");
error.printError(); error.printError();
return 1; return 1;
} }
@ -411,7 +411,7 @@ public:
dset_para[i] = new DataSet(fd->createDataSet(ParameterNames[i], ParameterDataTypes[i], *dspace_para)); dset_para[i] = new DataSet(fd->createDataSet(ParameterNames[i], ParameterDataTypes[i], *dspace_para));
} }
catch(Exception error){ 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(); error.printError();
fd->close(); fd->close();
return 1; return 1;
@ -527,12 +527,12 @@ public:
//setect hyperslabs //setect hyperslabs
if (H5Sselect_hyperslab (vdsDataspace, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) { 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; error = true;
break; break;
} }
if (H5Sselect_hyperslab (vdsDataspace_para, H5S_SELECT_SET, offset_para, NULL, count_para, NULL) < 0) { 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; error = true;
break; break;
} }
@ -559,14 +559,14 @@ public:
//mapping //mapping
if (H5Pset_virtual(dcpl, vdsDataspace, srcFileName.c_str(), srcDatasetName.c_str(), srcDataspace) < 0) { 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; error = true;
break; break;
} }
for (int k = 0; k < NumberofParameters; ++k) { for (int k = 0; k < NumberofParameters; ++k) {
if (H5Pset_virtual(dcpl_para[k], vdsDataspace_para, srcFileName.c_str(), ParameterNames[k], srcDataspace_para) < 0) { 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; error = true;
break; break;
} }
@ -639,7 +639,7 @@ public:
data_out = (T*)malloc(sizeof(T)*(nDimx*nDimy*nDimz)); data_out = (T*)malloc(sizeof(T)*(nDimx*nDimy*nDimz));
break; break;
default: default:
bprintf(RED,"invalid rank. Options: 2 or 3\n"); cprintf(RED,"invalid rank. Options: 2 or 3\n");
return 0; return 0;
} }
if (datatype == PredType::STD_U16LE) { if (datatype == PredType::STD_U16LE) {
@ -696,7 +696,7 @@ public:
newfd->close(); newfd->close();
oldfd->close(); oldfd->close();
} catch(Exception error){ } catch(Exception error){
bprintf(RED,"Error in copying virtual files\n"); cprintf(RED,"Error in copying virtual files\n");
error.printError(); error.printError();
free(data_out); free(data_out);
oldfd->close(); oldfd->close();
@ -780,7 +780,7 @@ public:
* @returns 1 for fail * @returns 1 for fail
*/ */
static int CloseFileOnError(hid_t& fd, const string msg) { static int CloseFileOnError(hid_t& fd, const string msg) {
bprintf(RED, "%s", msg.c_str()); cprintf(RED, "%s", msg.c_str());
if(fd > 0) if(fd > 0)
H5Fclose(fd); H5Fclose(fd);
fd = 0; fd = 0;
@ -803,7 +803,7 @@ public:
else if (dtype == PredType::STD_U64LE) else if (dtype == PredType::STD_U64LE)
return H5T_STD_U64LE; return H5T_STD_U64LE;
else { else {
bprintf(RED, "Invalid Data type\n"); cprintf(RED, "Invalid Data type\n");
return H5T_STD_U64LE; return H5T_STD_U64LE;
} }
} }

View File

@ -659,7 +659,7 @@ enum communicationProtocol{
continue; continue;
if(nsent != nsending){ if(nsent != nsending){
if(nsent && (nsent != -1)) if(nsent && (nsent != -1))
bprintf(RED,"Incomplete Packet size %d\n",nsent); cprintf(RED,"Incomplete Packet size %d\n",nsent);
break; break;
} }
length-=nsent; length-=nsent;
@ -672,7 +672,7 @@ enum communicationProtocol{
nsending=packet_size; nsending=packet_size;
while(1){ while(1){
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
bprintf(BLUE,"%d gonna listen\n", portno); fflush(stdout); cprintf(BLUE,"%d gonna listen\n", portno); fflush(stdout);
#endif #endif
nsent = recvfrom(socketDescriptor,(char*)buf+total_sent,nsending, 0, (struct sockaddr *) &clientAddress, &clientAddress_length); 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) //break out of loop only if read one packets size or read didnt work (cuz of shutdown)
@ -680,7 +680,7 @@ enum communicationProtocol{
break; break;
//incomplete packets or header packets ignored and read buffer again //incomplete packets or header packets ignored and read buffer again
if(nsent != packet_size && nsent != header_packet_size) 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; //nsent = 1040;
if(nsent > 0)total_sent+=nsent; if(nsent > 0)total_sent+=nsent;

View File

@ -218,10 +218,9 @@ inline void Output2FILE::Output(const std::string& msg, TLogLevel level)
return; return;
bool out = true; bool out = true;
switch(level){ switch(level){
case logERROR: bprintf(RED BOLD,"%s",msg.c_str()); break; case logERROR: cprintf(RED BOLD,"%s",msg.c_str()); break;
case logWARNING: bprintf(YELLOW BOLD,"%s",msg.c_str()); break; case logWARNING: cprintf(YELLOW BOLD,"%s",msg.c_str()); break;
case logINFO: bprintf(GRAY,"%s",msg.c_str()); break; case logINFO: cprintf(DARKGRAY,"%s",msg.c_str()); break;
// case logINFO: bprintf(DARKGRAY BOLD,"%s",msg.c_str());break;
default: fprintf(pStream,"%s",msg.c_str()); out = false; break; default: fprintf(pStream,"%s",msg.c_str()); out = false; break;
} }
fflush(out ? stdout : pStream); fflush(out ? stdout : pStream);

View File

@ -80,7 +80,7 @@ int BinaryFile::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_
numActualPacketsInFile += nump; numActualPacketsInFile += nump;
if (BinaryFileStatic::WriteDataFile(filefd, buffer, buffersize, fnum) == buffersize) if (BinaryFileStatic::WriteDataFile(filefd, buffer, buffersize, fnum) == buffersize)
return OK; 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; return FAIL;
} }

View File

@ -183,7 +183,7 @@ void DataProcessor::RecordFirstIndices(uint64_t fnum) {
} }
#ifdef VERBOSE #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); index, (long long int)firstAcquisitionIndex, (long long int)firstMeasurementIndex);
#endif #endif
} }
@ -293,13 +293,13 @@ void DataProcessor::ThreadExecution() {
char* buffer=0; char* buffer=0;
fifo->PopAddress(buffer); fifo->PopAddress(buffer);
#ifdef FIFODEBUG #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 #endif
//check dummy //check dummy
uint32_t numBytes = (uint32_t)(*((uint32_t*)buffer)); uint32_t numBytes = (uint32_t)(*((uint32_t*)buffer));
#ifdef VERBOSE #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 #endif
if (numBytes == DUMMY_PACKET_VALUE) { if (numBytes == DUMMY_PACKET_VALUE) {
StopProcessing(buffer); StopProcessing(buffer);
@ -319,7 +319,7 @@ void DataProcessor::ThreadExecution() {
void DataProcessor::StopProcessing(char* buf) { void DataProcessor::StopProcessing(char* buf) {
#ifdef VERBOSE #ifdef VERBOSE
if (!index) if (!index)
bprintf(RED,"DataProcessing %d: Dummy\n", index); cprintf(RED,"DataProcessing %d: Dummy\n", index);
#endif #endif
//stream or free //stream or free
if (*dataStreamEnable) if (*dataStreamEnable)
@ -350,12 +350,12 @@ void DataProcessor::ProcessAnImage(char* buf) {
#ifdef VERBOSE #ifdef VERBOSE
if (!index) if (!index)
bprintf(BLUE,"DataProcessing %d: fnum:%lu\n", index, fnum); cprintf(BLUE,"DataProcessing %d: fnum:%lu\n", index, fnum);
#endif #endif
if (!measurementStartedFlag) { if (!measurementStartedFlag) {
#ifdef VERBOSE #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 #endif
RecordFirstIndices(fnum); RecordFirstIndices(fnum);
@ -418,7 +418,7 @@ bool DataProcessor::CheckTimer() {
struct timespec end; struct timespec end;
clock_gettime(CLOCK_REALTIME, &end); clock_gettime(CLOCK_REALTIME, &end);
#ifdef VERBOSE #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 #endif
//still less than streaming timer, keep waiting //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)) if((( end.tv_sec - timerBegin.tv_sec ) + ( end.tv_nsec - timerBegin.tv_nsec ) / 1000000000.0) < ((double)*streamingTimerInMs/1000.00))

View File

@ -139,7 +139,7 @@ void DataStreamer::RecordFirstIndices(uint64_t fnum) {
} }
#ifdef VERBOSE #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); index, (long long int)firstAcquisitionIndex, (long long int)firstMeasurementIndex);
#endif #endif
} }
@ -167,7 +167,7 @@ int DataStreamer::CreateZmqSockets(int* nunits, uint32_t port) {
zmqSocket = new ZmqSocket(portnum); zmqSocket = new ZmqSocket(portnum);
if (zmqSocket->IsError()) { 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; return FAIL;
} }
FILE_LOG(logINFO) << index << " Streamer: Zmq Server started at " << zmqSocket->GetZmqServerAddress(); FILE_LOG(logINFO) << index << " Streamer: Zmq Server started at " << zmqSocket->GetZmqServerAddress();
@ -187,13 +187,13 @@ void DataStreamer::ThreadExecution() {
char* buffer=0; char* buffer=0;
fifo->PopAddressToStream(buffer); fifo->PopAddressToStream(buffer);
#ifdef FIFODEBUG #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 #endif
//check dummy //check dummy
uint32_t numBytes = (uint32_t)(*((uint32_t*)buffer)); uint32_t numBytes = (uint32_t)(*((uint32_t*)buffer));
#ifdef VERBOSE #ifdef VERBOSE
bprintf(GREEN,"DataStreamer %d, Numbytes:%u\n", index,numBytes); cprintf(GREEN,"DataStreamer %d, Numbytes:%u\n", index,numBytes);
#endif #endif
if (numBytes == DUMMY_PACKET_VALUE) { if (numBytes == DUMMY_PACKET_VALUE) {
StopProcessing(buffer); StopProcessing(buffer);
@ -212,12 +212,12 @@ void DataStreamer::ThreadExecution() {
void DataStreamer::StopProcessing(char* buf) { void DataStreamer::StopProcessing(char* buf) {
#ifdef VERBOSE #ifdef VERBOSE
if (!index) if (!index)
bprintf(RED,"DataStreamer %d: Dummy\n", index); cprintf(RED,"DataStreamer %d: Dummy\n", index);
#endif #endif
sls_detector_header* header = (sls_detector_header*) (buf); sls_detector_header* header = (sls_detector_header*) (buf);
//send dummy header and data //send dummy header and data
if (!SendHeader(header, true)) 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); fifo->FreeAddress(buf);
StopRunning(); StopRunning();
@ -232,31 +232,31 @@ void DataStreamer::ProcessAnImage(char* buf) {
sls_detector_header* header = (sls_detector_header*) (buf); sls_detector_header* header = (sls_detector_header*) (buf);
uint64_t fnum = header->frameNumber; uint64_t fnum = header->frameNumber;
#ifdef VERBOSE #ifdef VERBOSE
bprintf(MAGENTA,"DataStreamer %d: fnum:%lu\n", index,fnum); cprintf(MAGENTA,"DataStreamer %d: fnum:%lu\n", index,fnum);
#endif #endif
if (!measurementStartedFlag) { if (!measurementStartedFlag) {
#ifdef VERBOSE #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 #endif
RecordFirstIndices(fnum); RecordFirstIndices(fnum);
} }
if (!SendHeader(header)) 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); (long long int) fnum, index);
//shortframe gotthard - data sending //shortframe gotthard - data sending
if (completeBuffer) { if (completeBuffer) {
memcpy(completeBuffer + ((generalData->imageSize)**shortFrameEnable), buf + sizeof(sls_detector_header), generalData->imageSize); memcpy(completeBuffer + ((generalData->imageSize)**shortFrameEnable), buf + sizeof(sls_detector_header), generalData->imageSize);
if (!zmqSocket->SendData(completeBuffer, generalData->imageSize_Streamer)) 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); (long long int) fnum, index);
} }
//normal - data sending //normal - data sending
else { else {
if (!zmqSocket->SendData(buf + sizeof(sls_detector_header), generalData->imageSize)) 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); (long long int) fnum, index);
} }
} }

View File

@ -32,7 +32,7 @@ Fifo::Fifo(uint32_t fifoItemSize, uint32_t depth, bool &success):
Fifo::~Fifo() { Fifo::~Fifo() {
FILE_LOG (logDEBUG) << __AT__ << " called"; FILE_LOG (logDEBUG) << __AT__ << " called";
//bprintf(BLUE,"Fifo Object %d: Goodbye\n", index); //cprintf(BLUE,"Fifo Object %d: Goodbye\n", index);
DestroyFifos(); DestroyFifos();
NumberofFifoClassObjects--; NumberofFifoClassObjects--;
} }
@ -64,7 +64,7 @@ int Fifo::CreateFifos(uint32_t fifoItemSize) {
while (buffer < (memory + fifoItemSize * (fifoDepth-1))) { while (buffer < (memory + fifoItemSize * (fifoDepth-1))) {
//sprintf(buffer,"memory"); //sprintf(buffer,"memory");
#ifdef FIFODEBUG #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 #endif
FreeAddress(buffer); FreeAddress(buffer);
buffer += fifoItemSize; buffer += fifoItemSize;

View File

@ -109,7 +109,7 @@ int HDF5File::CreateFile(uint64_t fnum) {
} }
pthread_mutex_unlock(&Mutex); pthread_mutex_unlock(&Mutex);
if (dataspace == NULL) if (dataspace == NULL)
bprintf(RED,"Got nothing!\n"); cprintf(RED,"Got nothing!\n");
if(!silentMode) if(!silentMode)
FILE_LOG(logINFO) << *udpPortNumber << ": HDF5 File created: " << currentFileName; 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); 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; return FAIL;
} }

View File

@ -190,7 +190,7 @@ void Listener::RecordFirstIndices(uint64_t fnum) {
} }
if(!SilentMode) { 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", "%d First Measurement Index:%lu\n",
index, firstAcquisitionIndex, index, firstAcquisitionIndex,
index, firstMeasurementIndex); index, firstMeasurementIndex);
@ -262,7 +262,7 @@ void Listener::ThreadExecution() {
fifo->GetNewAddress(buffer); fifo->GetNewAddress(buffer);
#ifdef FIFODEBUG #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 #endif
//udpsocket doesnt exist //udpsocket doesnt exist
@ -325,8 +325,8 @@ void Listener::StopListening(char* buf) {
udpSocket = 0; udpSocket = 0;
} }
#ifdef VERBOSE #ifdef VERBOSE
bprintf(GREEN,"%d: Listening Packets (%u) : %llu\n", index, *udpPortNumber, numPacketsCaught); cprintf(GREEN,"%d: Listening Packets (%u) : %llu\n", index, *udpPortNumber, numPacketsCaught);
bprintf(GREEN,"%d: Listening Completed\n", index); cprintf(GREEN,"%d: Listening Completed\n", index);
#endif #endif
} }
@ -355,7 +355,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
//look for carry over //look for carry over
if (carryOverFlag) { if (carryOverFlag) {
//bprintf(RED,"%d carry flag\n",index); //cprintf(RED,"%d carry flag\n",index);
//check if its the current image packet //check if its the current image packet
// -------------------------- new header ---------------------------------------------------------------------- // -------------------------- new header ----------------------------------------------------------------------
if (standardheader) { if (standardheader) {
@ -371,7 +371,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
//------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------
if (fnum != currentFrameIndex) { if (fnum != currentFrameIndex) {
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; return 0;
} }
new_header->packetNumber = numpackets; new_header->packetNumber = numpackets;
@ -463,7 +463,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
#ifdef VERBOSE #ifdef VERBOSE
//if (!index) //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); index,currentFrameIndex, fnum, pnum, numpackets);
#endif #endif
if (!measurementStartedFlag) if (!measurementStartedFlag)
@ -471,7 +471,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
//future packet by looking at image number (all other detectors) //future packet by looking at image number (all other detectors)
if (fnum != currentFrameIndex) { 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; carryOverFlag = true;
memcpy(carryOverPacket,listeningPacket, generalData->packetSize); memcpy(carryOverPacket,listeningPacket, generalData->packetSize);
@ -547,9 +547,9 @@ void Listener::PrintFifoStatistics() {
numFramesStatistic = 0; numFramesStatistic = 0;
if (loss) 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); *udpPortNumber,loss, fifo->GetMaxLevelForFifoBound() , fifo->GetMinLevelForFifoFree(), currentFrameIndex);
else 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); *udpPortNumber,loss, fifo->GetMaxLevelForFifoBound(), fifo->GetMinLevelForFifoFree(), currentFrameIndex);
} }

View File

@ -75,7 +75,7 @@ void* ThreadObject::StartThread(void* thisPointer) {
void ThreadObject::RunningThread() { 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(true) {
while(IsRunning()) { while(IsRunning()) {
@ -89,7 +89,7 @@ void ThreadObject::RunningThread() {
sem_wait(&semaphore); sem_wait(&semaphore);
if(killThread) { 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); pthread_exit(NULL);
} }

View File

@ -147,7 +147,7 @@ void UDPStandardImplementation::setFileWriteEnable(const bool b){
int UDPStandardImplementation::setShortFrameEnable(const int i) { int UDPStandardImplementation::setShortFrameEnable(const int i) {
if (myDetectorType != GOTTHARD) { 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; return FAIL;
} }
@ -218,9 +218,9 @@ int UDPStandardImplementation::setDataStreamEnable(const bool enable) {
} }
if (DataStreamer::GetErrorMask() || error) { if (DataStreamer::GetErrorMask() || error) {
if (DataStreamer::GetErrorMask()) if (DataStreamer::GetErrorMask())
bprintf(RED,"Error: Could not create data callback threads\n"); cprintf(RED,"Error: Could not create data callback threads\n");
else else
bprintf(RED,"Error: Could not create zmq sockets\n"); cprintf(RED,"Error: Could not create zmq sockets\n");
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
delete(*it); delete(*it);
dataStreamer.clear(); dataStreamer.clear();
@ -393,7 +393,7 @@ void UDPStandardImplementation::resetAcquisitionCount() {
int UDPStandardImplementation::startReceiver(char *c) { int UDPStandardImplementation::startReceiver(char *c) {
bprintf(GRAY,"\n"); cprintf(DARKGRAY,"\n");
FILE_LOG(logINFO) << "Starting Receiver"; FILE_LOG(logINFO) << "Starting Receiver";
ResetParametersforNewMeasurement(); ResetParametersforNewMeasurement();
@ -481,19 +481,19 @@ void UDPStandardImplementation::stopReceiver(){
uint64_t missingpackets = numberOfFrames*generalData->packetsPerFrame-listener[i]->GetPacketsCaught(); uint64_t missingpackets = numberOfFrames*generalData->packetsPerFrame-listener[i]->GetPacketsCaught();
if (missingpackets) { if (missingpackets) {
bprintf(RED, "\n[Port %d]\n",udpPortNum[i]); cprintf(RED, "\n[Port %d]\n",udpPortNum[i]);
bprintf(RED, "Missing Packets\t\t: %lld\n",(long long int)missingpackets); cprintf(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()); cprintf(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, "Last Frame Caught\t: %lld\n",(long long int)listener[i]->GetLastFrameIndexCaught());
}else{ }else{
bprintf(GREEN, "\n[Port %d]\n",udpPortNum[i]); cprintf(GREEN, "\n[Port %d]\n",udpPortNum[i]);
bprintf(GREEN, "Missing Packets\t\t: %lld\n",(long long int)missingpackets); cprintf(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()); cprintf(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, "Last Frame Caught\t: %lld\n",(long long int)listener[i]->GetLastFrameIndexCaught());
} }
} }
if(!activated) if(!activated)
bprintf(RED,"Note: Deactivated Receiver\n"); cprintf(RED,"Note: Deactivated Receiver\n");
//callback //callback
if (acquisitionFinishedCallBack) if (acquisitionFinishedCallBack)
acquisitionFinishedCallBack((tot/numThreads), pAcquisitionFinished); acquisitionFinishedCallBack((tot/numThreads), pAcquisitionFinished);
@ -525,7 +525,7 @@ void UDPStandardImplementation::startReadout(){
//wait as long as there is change from prev totalP, //wait as long as there is change from prev totalP,
while(prev != totalP){ while(prev != totalP){
#ifdef VERY_VERBOSE #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); prev,totalP);
#endif #endif
@ -538,7 +538,7 @@ void UDPStandardImplementation::startReadout(){
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it) for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
totalP += (*it)->GetPacketsCaught(); totalP += (*it)->GetPacketsCaught();
#ifdef VERY_VERBOSE #ifdef VERY_VERBOSE
bprintf(MAGENTA,"\tupdated: totalP:%d\n",totalP); cprintf(MAGENTA,"\tupdated: totalP:%d\n",totalP);
#endif #endif
} }
} }
@ -629,7 +629,7 @@ int UDPStandardImplementation::SetupFifoStructure() {
(generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize), (generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize),
fifoDepth, success)); fifoDepth, success));
if (!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<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it) for (vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
delete(*it); delete(*it);
fifo.clear(); fifo.clear();

View File

@ -60,7 +60,7 @@ void GetData(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, ui
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
keeprunning = true; 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 // Catch signal SIGINT to close files and call destructors properly
struct sigaction sa; struct sigaction sa;
@ -68,7 +68,7 @@ int main(int argc, char *argv[]) {
sa.sa_handler=sigInterruptHandler; // handler function sa.sa_handler=sigInterruptHandler; // handler function
sigemptyset(&sa.sa_mask); // dont block additional signals during invocation of handler sigemptyset(&sa.sa_mask); // dont block additional signals during invocation of handler
if (sigaction(SIGINT, &sa, NULL) == -1) { 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 asa.sa_handler=SIG_IGN; // handler function
sigemptyset(&asa.sa_mask); // dont block additional signals during invocation of handler sigemptyset(&asa.sa_mask); // dont block additional signals during invocation of handler
if (sigaction(SIGPIPE, &asa, NULL) == -1) { 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); slsReceiverUsers *receiver = new slsReceiverUsers(argc, argv, ret);
if(ret==slsReceiverDefs::FAIL){ if(ret==slsReceiverDefs::FAIL){
delete receiver; 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); exit(EXIT_FAILURE);
} }
@ -136,17 +136,17 @@ int main(int argc, char *argv[]) {
//start tcp server thread //start tcp server thread
if (receiver->start() == slsReceiverDefs::FAIL){ if (receiver->start() == slsReceiverDefs::FAIL){
delete receiver; 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); exit(EXIT_FAILURE);
} }
FILE_LOG(logINFO) << "Ready ... "; FILE_LOG(logINFO) << "Ready ... ";
bprintf(GRAY, "\n[ Press \'Ctrl+c\' to exit ]\n"); cprintf(DARKGRAY, "\n[ Press \'Ctrl+c\' to exit ]\n");
while(keeprunning) while(keeprunning)
pause(); pause();
delete receiver; 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!"; FILE_LOG(logINFO) << "Goodbye!";
return 0; return 0;
} }

View File

@ -186,7 +186,7 @@ void* slsReceiverTCPIPInterface::startTCPServerThread(void *this_pointer){
void slsReceiverTCPIPInterface::startTCPServer(){ 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 #ifdef VERYVERBOSE
FILE_LOG(logDEBUG5) << "Starting Receiver TCP Server"; FILE_LOG(logDEBUG5) << "Starting Receiver TCP Server";
@ -222,7 +222,7 @@ void slsReceiverTCPIPInterface::startTCPServer(){
} }
mySock->exitServer(); 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); pthread_exit(NULL);
} }
@ -233,7 +233,7 @@ void slsReceiverTCPIPInterface::startTCPServer(){
receiverBase->shutDownUDPSockets(); 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); pthread_exit(NULL);
} }
@ -345,7 +345,7 @@ int slsReceiverTCPIPInterface::function_table(){
int slsReceiverTCPIPInterface::decode_function(){ int slsReceiverTCPIPInterface::decode_function(){
ret = FAIL; ret = FAIL;
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
bprintf(GRAY,"\n"); cprintf(DARKGRAY,"\n");
FILE_LOG(logDEBUG1) << "waiting to receive data"; FILE_LOG(logDEBUG1) << "waiting to receive data";
#endif #endif
int n = mySock->ReceiveDataOnly(&fnum,sizeof(fnum)); int n = mySock->ReceiveDataOnly(&fnum,sizeof(fnum));
@ -475,7 +475,7 @@ int slsReceiverTCPIPInterface::exit_server() {
strcpy(mess,"closing server"); strcpy(mess,"closing server");
mySock->SendDataOnly(&ret,sizeof(ret)); mySock->SendDataOnly(&ret,sizeof(ret));
mySock->SendDataOnly(mess,sizeof(mess)); mySock->SendDataOnly(mess,sizeof(mess));
bprintf(RED,"%s\n",mess); cprintf(RED,"%s\n",mess);
return ret; return ret;
} }

View File

@ -54,9 +54,9 @@ int read_config_file(string fname, int *tcpip_port_no, map<string, string> * con
if(sstr.good()) { if(sstr.good()) {
sstr >> sargname; sstr >> sargname;
if(sscanf(sargname.c_str(),"%d",tcpip_port_no)) 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{ 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; success = slsReceiverDefs::FAIL;
} }
} }