added black background for reciever to see gray font better

This commit is contained in:
Dhanya Maliakal
2017-06-30 12:19:27 +02:00
parent 4b9a8c1dad
commit a4c07ba9a0
29 changed files with 337 additions and 957 deletions

View File

@ -35,8 +35,8 @@ BinaryFile::~BinaryFile() {
void BinaryFile::PrintMembers() {
File::PrintMembers();
printf("Max Frames Per File: %d\n",maxFramesPerFile);
printf("Number of Frames in File: %d\n",numFramesInFile);
FILE_LOG(logINFO) << "Max Frames Per File: " << maxFramesPerFile;
FILE_LOG(logINFO) << "Number of Frames in File: " << numFramesInFile;
}
slsReceiverDefs::fileFormat BinaryFile::GetFileType() {
@ -61,14 +61,14 @@ int BinaryFile::CreateFile(uint64_t fnum) {
//first file, print entrire path
if (loss == -1)
printf("[%u]: Binary File created: %s\n", *udpPortNumber, currentFileName.c_str());
FILE_LOG(logINFO) << "[" << *udpPortNumber << "]: Binary File created: " << currentFileName;
//other files
else {
if (loss)
cprintf(RED,"[%u]: Packet_Loss:%lu Fifo_Max_Level:%d \tNew_File:%s\n",
bprintf(RED,"[%u]: Packet_Loss:%lu Fifo_Max_Level:%d \tNew_File:%s\n",
*udpPortNumber,loss, fifo->GetMaxLevelForFifoBound() , basename(currentFileName.c_str()));
else
cprintf(GREEN,"[%u]: Packet_Loss:%lu Fifo_Max_Level:%d \tNew_File:%s\n",
bprintf(GREEN,"[%u]: Packet_Loss:%lu Fifo_Max_Level:%d \tNew_File:%s\n",
*udpPortNumber,loss, fifo->GetMaxLevelForFifoBound(), basename(currentFileName.c_str()));
}
@ -94,7 +94,7 @@ int BinaryFile::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_
numActualPacketsInFile += nump;
if (BinaryFileStatic::WriteDataFile(filefd, buffer, buffersize, fnum) == buffersize)
return OK;
cprintf(RED,"%d Error: Write to file failed for image number %lld\n", index, (long long int)fnum);
bprintf(RED,"%d Error: Write to file failed for image number %lld\n", index, (long long int)fnum);
return FAIL;
}
@ -107,7 +107,7 @@ int BinaryFile::CreateMasterFile(bool en, uint32_t size,
if (master && (*detIndex==0)) {
masterFileName = BinaryFileStatic::CreateMasterFileName(filePath, fileNamePrefix, *fileIndex);
printf("Master File: %s\n", masterFileName.c_str());
FILE_LOG(logINFO) << "Master File: " << masterFileName;
return BinaryFileStatic::CreateMasterDataFile(masterfd, masterFileName, *overWriteEnable,
*dynamicRange, en, size, nx, ny, *numImages,
at, ap, BINARY_WRITER_VERSION);

View File

@ -168,7 +168,7 @@ void DataProcessor::RecordFirstIndices(uint64_t fnum) {
}
#ifdef VERBOSE
cprintf(BLUE,"%d First Acquisition Index:%lld\tFirst Measurement Index:%lld\n",
bprintf(BLUE,"%d First Acquisition Index:%lld\tFirst Measurement Index:%lld\n",
index, (long long int)firstAcquisitionIndex, (long long int)firstMeasurementIndex);
#endif
}
@ -270,13 +270,13 @@ void DataProcessor::ThreadExecution() {
char* buffer=0;
fifo->PopAddress(buffer);
#ifdef FIFODEBUG
if (!index) cprintf(BLUE,"DataProcessor %d, pop 0x%p buffer:%s\n", index,(void*)(buffer),buffer);
if (!index) bprintf(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) cprintf(BLUE,"DataProcessor %d, Numbytes:%u\n", index,numBytes);
if (!index) bprintf(BLUE,"DataProcessor %d, Numbytes:%u\n", index,numBytes);
#endif
if (numBytes == DUMMY_PACKET_VALUE) {
StopProcessing(buffer);
@ -297,7 +297,7 @@ void DataProcessor::ThreadExecution() {
void DataProcessor::StopProcessing(char* buf) {
#ifdef VERBOSE
if (!index)
cprintf(RED,"DataProcessing %d: Dummy\n", index);
bprintf(RED,"DataProcessing %d: Dummy\n", index);
#endif
//stream or free
if (*dataStreamEnable)
@ -308,7 +308,7 @@ void DataProcessor::StopProcessing(char* buf) {
file->CloseCurrentFile();
StopRunning();
#ifdef VERBOSE
printf("%d: Processing Completed\n", index);
FILE_LOG(logINFO) << index << ": Processing Completed";
#endif
}
@ -326,12 +326,12 @@ void DataProcessor::ProcessAnImage(char* buf) {
#ifdef VERBOSE
if (!index)
cprintf(BLUE,"DataProcessing %d: fnum:%lu\n", index, fnum);
bprintf(BLUE,"DataProcessing %d: fnum:%lu\n", index, fnum);
#endif
if (!measurementStartedFlag) {
#ifdef VERBOSE
if (!index) cprintf(BLUE,"DataProcessing %d: fnum:%lu\n", index, fnum);
if (!index) bprintf(BLUE,"DataProcessing %d: fnum:%lu\n", index, fnum);
#endif
RecordFirstIndices(fnum);
}

View File

@ -135,7 +135,7 @@ void DataStreamer::RecordFirstIndices(uint64_t fnum) {
}
#ifdef VERBOSE
cprintf(BLUE,"%d First Acquisition Index:%lld\tFirst Measurement Index:%lld\n",
bprintf(BLUE,"%d First Acquisition Index:%lld\tFirst Measurement Index:%lld\n",
index, (long long int)firstAcquisitionIndex, (long long int)firstMeasurementIndex);
#endif
}
@ -166,10 +166,10 @@ int DataStreamer::CreateZmqSockets(int* dindex, int* nunits) {
zmqSocket = new ZmqSocket(portnum);
if (zmqSocket->IsError()) {
cprintf(RED, "Error: Could not create Zmq socket on port %d for Streamer %d\n", portnum, index);
bprintf(RED, "Error: Could not create Zmq socket on port %d for Streamer %d\n", portnum, index);
return FAIL;
}
printf("%d Streamer: Zmq Server started at %s\n",index, zmqSocket->GetZmqServerAddress());
FILE_LOG(logINFO) << index << " Streamer: Zmq Server started at " << zmqSocket->GetZmqServerAddress();
return OK;
}
@ -186,13 +186,13 @@ void DataStreamer::ThreadExecution() {
char* buffer=0;
fifo->PopAddressToStream(buffer);
#ifdef FIFODEBUG
if (!index) cprintf(BLUE,"DataStreamer %d, pop 0x%p buffer:%s\n", index,(void*)(buffer),buffer);
if (!index) bprintf(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
cprintf(GREEN,"DataStreamer %d, Numbytes:%u\n", index,numBytes);
bprintf(GREEN,"DataStreamer %d, Numbytes:%u\n", index,numBytes);
#endif
if (numBytes == DUMMY_PACKET_VALUE) {
StopProcessing(buffer);
@ -211,17 +211,17 @@ void DataStreamer::ThreadExecution() {
void DataStreamer::StopProcessing(char* buf) {
#ifdef VERBOSE
if (!index)
cprintf(RED,"DataStreamer %d: Dummy\n", index);
bprintf(RED,"DataStreamer %d: Dummy\n", index);
#endif
sls_detector_header* header = (sls_detector_header*) (buf);
//send dummy header and data
if (!SendHeader(header, true))
cprintf(RED,"Error: Could not send zmq dummy header for streamer %d\n", index);
bprintf(RED,"Error: Could not send zmq dummy header for streamer %d\n", index);
fifo->FreeAddress(buf);
StopRunning();
#ifdef VERBOSE
printf("%d: Streaming Completed\n", index);
FILE_LOG(logINFO) << index << ": Streaming Completed";
#endif
}
@ -231,12 +231,12 @@ void DataStreamer::ProcessAnImage(char* buf) {
sls_detector_header* header = (sls_detector_header*) (buf);
uint64_t fnum = header->frameNumber;
#ifdef VERBOSE
cprintf(MAGENTA,"DataStreamer %d: fnum:%lu\n", index,fnum);
bprintf(MAGENTA,"DataStreamer %d: fnum:%lu\n", index,fnum);
#endif
if (!measurementStartedFlag) {
#ifdef VERBOSE
if (!index) cprintf(MAGENTA,"DataStreamer %d: fnum:%lu\n", index, fnum);
if (!index) bprintf(MAGENTA,"DataStreamer %d: fnum:%lu\n", index, fnum);
#endif
RecordFirstIndices(fnum);
//restart timer
@ -255,20 +255,20 @@ void DataStreamer::ProcessAnImage(char* buf) {
}
if (!SendHeader(header))
cprintf(RED,"Error: Could not send zmq header for fnum %lld and streamer %d\n",
bprintf(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))
cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n",
bprintf(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))
cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n",
bprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n",
(long long int) fnum, index);
}
}
@ -279,7 +279,7 @@ bool DataStreamer::CheckTimer() {
struct timespec end;
clock_gettime(CLOCK_REALTIME, &end);
#ifdef VERBOSE
cprintf(BLUE,"%d Timer elapsed time:%f seconds\n", index, ( end.tv_sec - timerBegin.tv_sec ) + ( end.tv_nsec - timerBegin.tv_nsec ) / 1000000000.0);
bprintf(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) < (*streamingTimerInMs/1000))

View File

@ -29,7 +29,7 @@ Fifo::Fifo(uint32_t fifoItemSize, uint32_t fifoDepth, bool &success):
Fifo::~Fifo() {
FILE_LOG (logDEBUG) << __AT__ << " called";
//cprintf(BLUE,"Fifo Object %d: Goodbye\n", index);
//bprintf(BLUE,"Fifo Object %d: Goodbye\n", index);
DestroyFifos();
NumberofFifoClassObjects--;
}
@ -59,7 +59,7 @@ int Fifo::CreateFifos(uint32_t fifoItemSize, uint32_t fifoDepth) {
while (buffer < (memory + fifoItemSize * (fifoDepth-1))) {
//sprintf(buffer,"memory");
#ifdef FIFODEBUG
cprintf(MAGENTA,"Fifofree %d: value:%d, pop 0x%p\n", index, fifoFree->getSemValue(), (void*)(buffer));
bprintf(MAGENTA,"Fifofree %d: value:%d, pop 0x%p\n", index, fifoFree->getSemValue(), (void*)(buffer));
#endif
FreeAddress(buffer);
buffer += fifoItemSize;

View File

@ -43,43 +43,25 @@ string File::GetCurrentFileName() {
}
void File::PrintMembers() {
printf("\nGeneral Writer Variables:"
"Index: %d\n"
"Max Frames Per File: %u\n"
"Packets per Frame: %u\n"
"Number of Detectors in x dir: %d\n"
"Number of Detectors in y dir: %d\n"
"File Name Prefix: %s\n"
"File Path: %s\n"
"File Index: %lu\n"
"Frame Index Enable: %d\n"
"Over Write Enable: %d\n"
FILE_LOG(logINFO) << "\nGeneral Writer Variables:" << endl
<< "Index: " << index << endl
<< "Max Frames Per File: " << maxFramesPerFile << endl
<< "Packets per Frame: " << *packetsPerFrame << endl
<< "Number of Detectors in x dir: " << numDetX << endl
<< "Number of Detectors in y dir: " << numDetY << endl
<< "File Name Prefix: " << fileNamePrefix << endl
<< "File Path: " << filePath << endl
<< "File Index: " << *fileIndex << endl
<< "Frame Index Enable: " << *frameIndexEnable << endl
<< "Over Write Enable: " << *overWriteEnable << endl
"Detector Index: %d\n"
"Number of Units Per Detector: %d\n"
"Number of Images in Acquisition: %lu\n"
"Dynamic Range: %u\n"
"UDP Port number: %u\n"
"Master File Name: %s\n"
"Current File Name: %s\n",
index,
maxFramesPerFile,
*packetsPerFrame,
numDetX,
numDetY,
fileNamePrefix,
filePath,
*fileIndex,
(int)*frameIndexEnable,
(int)*overWriteEnable,
*detIndex,
*numUnitsPerDetector,
*numImages,
*dynamicRange,
*udpPortNumber,
masterFileName.c_str(),
currentFileName.c_str());
<< "Detector Index: " << *detIndex << endl
<< "Number of Units Per Detector: " << *numUnitsPerDetector << endl
<< "Number of Images in Acquisition: " << *numImages << endl
<< "Dynamic Range: " << *dynamicRange << endl
<< "UDP Port number: " << *udpPortNumber << endl
<< "Master File Name: " << masterFileName << endl
<< "Current File Name: " << currentFileName;
}

View File

@ -53,13 +53,13 @@ void HDF5File::PrintMembers() {
File::PrintMembers();
UpdateDataType();
if (datatype == PredType::STD_U8LE) {
printf("Data Type: 4 or 8\n");
FILE_LOG(logINFO) << "Data Type: 4 or 8";
} else if (datatype == PredType::STD_U16LE) {
printf("Data Type: 16\n");
FILE_LOG(logINFO) << "Data Type: 16";
} else if (datatype == PredType::STD_U32LE) {
printf("Data Type: 32\n");
FILE_LOG(logINFO) << "Data Type: 32";
} else {
cprintf(BG_RED,"unknown data type\n");
FILE_LOG(logERROR) << BG_RED,"unknown data type";
}
}
@ -112,18 +112,18 @@ int HDF5File::CreateFile(uint64_t fnum) {
}
pthread_mutex_unlock(&Mutex);
if (dataspace == NULL)
cprintf(RED,"Got nothing!\n");
bprintf(RED,"Got nothing!\n");
//first file, print entrire path
if (loss == -1)
printf("[%u]: HDF5 File created: %s\n", *udpPortNumber, currentFileName.c_str());
FILE_LOG(logINFO) << *udpPortNumber << ": HDF5 File created: " << currentFileName;
//other files
else {
if (loss)
cprintf(RED,"[%u]: Packet_Loss:%lu Fifo_Max_Level:%d \tNew_File:%s\n",
bprintf(RED,"[%u]: Packet_Loss:%lu Fifo_Max_Level:%d \tNew_File:%s\n",
*udpPortNumber,loss, fifo->GetMaxLevelForFifoBound() , basename(currentFileName.c_str()));
else
cprintf(GREEN,"[%u]: Packet_Loss:%lu Fifo_Max_Level:%d \tNew_File:%s\n",
bprintf(GREEN,"[%u]: Packet_Loss:%lu Fifo_Max_Level:%d \tNew_File:%s\n",
*udpPortNumber,loss, fifo->GetMaxLevelForFifoBound(), basename(currentFileName.c_str()));
}
@ -172,7 +172,7 @@ int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t
}
}
pthread_mutex_unlock(&Mutex);
cprintf(RED,"%d Error: Write to file failed\n", index);
bprintf(RED,"%d Error: Write to file failed\n", index);
return FAIL;
}
@ -187,7 +187,7 @@ int HDF5File::CreateMasterFile(bool en, uint32_t size,
if (master && (*detIndex==0)) {
virtualfd = 0;
masterFileName = HDF5FileStatic::CreateMasterFileName(filePath, fileNamePrefix, *fileIndex);
printf("Master File: %s\n", masterFileName.c_str());
FILE_LOG(logINFO) << "Master File: " << masterFileName;
pthread_mutex_lock(&Mutex);
int ret = HDF5FileStatic::CreateMasterDataFile(masterfd, masterFileName, *overWriteEnable,
*dynamicRange, en, size, nx, ny, *numImages, at, ap, HDF5_WRITER_VERSION);

View File

@ -177,7 +177,7 @@ void Listener::RecordFirstIndices(uint64_t fnum) {
acquisitionStartedFlag = true;
firstAcquisitionIndex = fnum;
}
if (!index) cprintf(BLUE,"%d First Acquisition Index:%lu\n"
if (!index) bprintf(BLUE,"%d First Acquisition Index:%lu\n"
"%d First Measurement Index:%lu\n",
index, firstAcquisitionIndex,
index, firstMeasurementIndex);
@ -219,7 +219,7 @@ int Listener::CreateUDPSockets() {
generalData->packetSize, (strlen(eth)?eth:NULL), generalData->headerPacketSize);
int iret = udpSocket->getErrorStatus();
if(!iret){
cout << index << ": UDP port opened at port " << *udpPortNumber << endl;
FILE_LOG(logINFO) << index << ": UDP port opened at port " << *udpPortNumber;
}else{
FILE_LOG(logERROR) << "Could not create UDP socket on port " << *udpPortNumber << " error: " << iret;
return FAIL;
@ -247,7 +247,7 @@ void Listener::ThreadExecution() {
fifo->GetNewAddress(buffer);
#ifdef FIFODEBUG
if (!index) cprintf(GREEN,"Listener %d, pop 0x%p buffer:%s\n", index,(void*)(buffer),buffer);
if (!index) bprintf(GREEN,"Listener %d, pop 0x%p buffer:%s\n", index,(void*)(buffer),buffer);
#endif
//udpsocket doesnt exist
@ -275,7 +275,7 @@ void Listener::ThreadExecution() {
//error check, (should not be here) if not transmitting yet (previous if) rc should be > 0
if (rc <= 0) {
//cprintf(BG_RED,"Error:(Weird Early self shut down), UDP Sockets not shut down, but received nothing\n");
//bprintf(BG_RED,"Error:(Weird Early self shut down), UDP Sockets not shut down, but received nothing\n");
StopListening(buffer);
return;
}
@ -297,8 +297,8 @@ void Listener::StopListening(char* buf) {
fifo->PushAddress(buf);
StopRunning();
#ifdef VERBOSE
cprintf(GREEN,"%d: Listening Packets (%u) : %llu\n", index, *udpPortNumber, numPacketsCaught);
printf("%d: Listening Completed\n", index);
bprintf(GREEN,"%d: Listening Packets (%u) : %llu\n", index, *udpPortNumber, numPacketsCaught);
bprintf(GREEN,"%d: Listening Completed\n", index);
#endif
}
@ -327,7 +327,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
//look for carry over
if (carryOverFlag) {
cprintf(RED,"%d carry flag\n",index);
bprintf(RED,"%d carry flag\n",index);
//check if its the current image packet
// -------------------------- new header ----------------------------------------------------------------------
if (standardheader) {
@ -343,7 +343,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
//------------------------------------------------------------------------------------------------------------
if (fnum != currentFrameIndex) {
if (fnum < currentFrameIndex) {
cprintf(BG_RED,"Error:(Weird), With carry flag: Frame number %lu less than current frame number %lu\n", fnum, currentFrameIndex);
bprintf(BG_RED,"Error:(Weird), With carry flag: Frame number %lu less than current frame number %lu\n", fnum, currentFrameIndex);
return 0;
}
new_header->packetNumber = numpackets;
@ -426,7 +426,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
#ifdef VERBOSE
//if (!index)
cprintf(GREEN,"Listening %d: currentfindex:%lu, fnum:%lu, pnum:%u numpackets:%u\n",
bprintf(GREEN,"Listening %d: currentfindex:%lu, fnum:%lu, pnum:%u numpackets:%u\n",
index,currentFrameIndex, fnum, pnum, numpackets);
#endif
if (!measurementStartedFlag)
@ -436,7 +436,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
//future packet by looking at image number (all other detectors)
if (fnum != currentFrameIndex) {
//cprintf(RED,"setting carry over flag to true\n");
//bprintf(RED,"setting carry over flag to true\n");
carryOverFlag = true;
memcpy(carryOverPacket,listeningPacket, generalData->packetSize);

View File

@ -87,7 +87,7 @@ void ThreadObject::RunningThread() {
sem_wait(&semaphore);
if(killThread) {
cprintf(BLUE,"%s Thread %d: Goodbye\n",GetType().c_str(),index);
bprintf(BLUE,"%s Thread %d: Goodbye\n",GetType().c_str(),index);
pthread_exit(NULL);
}

View File

@ -133,7 +133,7 @@ void UDPStandardImplementation::setFileFormat(const fileFormat f){
int UDPStandardImplementation::setShortFrameEnable(const int i) {
if (myDetectorType != GOTTHARD) {
cprintf(RED, "Error: Can not set short frame for this detector\n");
bprintf(RED, "Error: Can not set short frame for this detector\n");
return FAIL;
}
@ -203,9 +203,9 @@ int UDPStandardImplementation::setDataStreamEnable(const bool enable) {
}
if (DataStreamer::GetErrorMask() || error) {
if (DataStreamer::GetErrorMask())
cprintf(BG_RED,"Error: Could not create data callback threads\n");
bprintf(BG_RED,"Error: Could not create data callback threads\n");
else
cprintf(BG_RED,"Error: Could not create zmq sockets\n");
bprintf(BG_RED,"Error: Could not create zmq sockets\n");
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
delete(*it);
dataStreamer.clear();
@ -319,7 +319,7 @@ int UDPStandardImplementation::setFifoDepth(const uint32_t i) {
if (SetupFifoStructure() == FAIL)
return FAIL;
}
FILE_LOG (logINFO) << "Fifo Depth: " << i << endl;
FILE_LOG (logINFO) << "Fifo Depth: " << i;
return OK;
}
@ -428,7 +428,7 @@ void UDPStandardImplementation::resetAcquisitionCount() {
int UDPStandardImplementation::startReceiver(char *c) {
cout << endl << endl;
bprintf(GRAY,"\n");
FILE_LOG(logINFO) << "Starting Receiver";
ResetParametersforNewMeasurement();
@ -445,7 +445,7 @@ int UDPStandardImplementation::startReceiver(char *c) {
startAcquisitionCallBack(filePath, fileName, fileIndex,
(generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize), pStartAcquisition);
if (rawDataReadyCallBack != NULL) {
cout << "Data Write has been defined externally" << endl;
FILE_LOG(logINFO) << "Data Write has been defined externally";
}
}
@ -457,9 +457,9 @@ int UDPStandardImplementation::startReceiver(char *c) {
return FAIL;
}
} else
cout << "File Write Disabled" << endl;
FILE_LOG(logINFO) << "File Write Disabled";
cout << "Ready ..." << endl;
FILE_LOG(logINFO) << "Ready ...";
//status
pthread_mutex_lock(&statusMutex);
@ -517,19 +517,19 @@ void UDPStandardImplementation::stopReceiver(){
uint64_t missingpackets = numberOfFrames*generalData->packetsPerFrame-listener[i]->GetPacketsCaught();
if (missingpackets) {
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());
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());
}else{
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());
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());
}
}
if(!activated)
cprintf(RED,"Note: Deactivated Receiver\n");
bprintf(RED,"Note: Deactivated Receiver\n");
//callback
if (acquisitionFinishedCallBack)
acquisitionFinishedCallBack((tot/numThreads), pAcquisitionFinished);
@ -563,7 +563,7 @@ void UDPStandardImplementation::startReadout(){
//wait as long as there is change from prev totalP,
while(prev != totalP){
#ifdef VERY_VERBOSE
cprintf(MAGENTA,"waiting for all packets prevP:%d totalP:%d\n",
bprintf(MAGENTA,"waiting for all packets prevP:%d totalP:%d\n",
prev,totalP);
#endif
@ -576,7 +576,7 @@ void UDPStandardImplementation::startReadout(){
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
totalP += (*it)->GetPacketsCaught();
#ifdef VERY_VERBOSE
cprintf(MAGENTA,"\tupdated: totalP:%d\n",totalP);
bprintf(MAGENTA,"\tupdated: totalP:%d\n",totalP);
#endif
}
}
@ -703,7 +703,7 @@ int UDPStandardImplementation::SetupFifoStructure() {
//must be > 0 and < max jobs
numberofJobs = ((i < 1) ? 1 : ((i > MAX_JOBS_PER_THREAD) ? MAX_JOBS_PER_THREAD : i));
}
FILE_LOG (logINFO) << "Number of Jobs Per Thread:" << numberofJobs << endl;
FILE_LOG (logINFO) << "Number of Jobs Per Thread:" << numberofJobs;
uint32_t oldfifodepth = fifoDepth;
//reduce fifo depth if numberofJobsPerBuffer > 1 (to save memory)
@ -731,7 +731,7 @@ int UDPStandardImplementation::SetupFifoStructure() {
(generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize),
fifoDepth, success));
if (!success) {
cprintf(BG_RED,"Error: Could not allocate memory for fifo structure of index %d\n", i);
bprintf(BG_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)
delete(*it);
fifo.clear();

View File

@ -1,48 +0,0 @@
/* A simple server in the internet domain using TCP
The port number is passed as an argument */
#include "sls_receiver_defs.h"
#include "dummyUDPInterface.h"
#include "slsReceiverTCPIPInterface.h"
#include <iostream>
#include <string.h>
using namespace std;
int main(int argc, char *argv[]) {
int success;
int tcpip_port_no;
bool bottom = false;
cout << "CCCCCC" << endl;
dummyUDPInterface *udp=new dummyUDPInterface();
// slsReceiverTCPIPInterface *tcpipInterface = new slsReceiverTCPIPInterface(success, udp, tcpip_port_no, bottom);
// if(tcpipInterface->start() == slsReceiverDefs::OK){
// cout << "DONE!" << endl;
// string str;
// cin>>str;
// //wait and look for an exit keyword
// while(str.find("exit") == string::npos)
// cin>>str;
// //stop tcp server thread, stop udp socket
// tcpipInterface->stop();
// }
// if (tcpipInterface)
// delete tcpipInterface;
udp->startReceiver();
if(udp)
delete udp;
return 0;
}

View File

@ -25,23 +25,23 @@ void closeFile(int p){
/*
int startAcquisitionCallBack(char* filePath, char* fileName, int fileIndex, int bufferSize, void* context) {
cout << "#### startAcquisitionCallBack ####" << endl;
cout << "* filePath: " << filePath << endl;
cout << "* fileName: " << fileName << endl;
cout << "* fileIndex: " << fileIndex << endl;
cout << "* bufferSize: " << bufferSize << endl;
FILE_LOG(logINFO) << "#### startAcquisitionCallBack ####";
FILE_LOG(logINFO) << "* filePath: " << filePath;
FILE_LOG(logINFO) << "* fileName: " << fileName;
FILE_LOG(logINFO) << "* fileIndex: " << fileIndex;
FILE_LOG(logINFO) << "* bufferSize: " << bufferSize;
return 1;
}
void acquisitionFinishedCallBack(int totalFramesCaught, void* context) {
cout << "#### acquisitionFinishedCallBack ####" << endl;
cout << "* totalFramesCaught: " << totalFramesCaught << endl;
FILE_LOG(logINFO) << "#### acquisitionFinishedCallBack ####";
FILE_LOG(logINFO) << "* totalFramesCaught: " << totalFramesCaught;
}
void rawDataReadyCallBack(int currFrameNum, char* dataPointer, int dataSize, FILE* file, char* guiDataPointer, void* context) {
cout << "#### rawDataReadyCallBack ####" << endl;
cout << "* currFrameNum: " << currFrameNum << endl;
cout << "* dataSize: " << dataSize << endl;
FILE_LOG(logINFO) << "#### rawDataReadyCallBack ####";
FILE_LOG(logINFO) << "* currFrameNum: " << currFrameNum;
FILE_LOG(logINFO) << "* dataSize: " << dataSize;
}
*/
@ -104,7 +104,7 @@ int main(int argc, char *argv[]) {
//start tcp server thread
if(receiver->start() == slsReceiverDefs::OK){
FILE_LOG(logDEBUG1) << "DONE!" << endl;
FILE_LOG(logDEBUG1) << "DONE!";
string str;
cin>>str;
//wait and look for an exit keyword
@ -115,7 +115,7 @@ int main(int argc, char *argv[]) {
}
deleteReceiver(receiver);
cout << "Goodbye!" << endl;
FILE_LOG(logINFO) << "Goodbye!";
return 0;
}

View File

@ -18,7 +18,7 @@ using namespace std;
slsReceiver::slsReceiver(int argc, char *argv[], int &success){
slsReceiver::slsReceiver(int argc, char *argv[], int &success) {
/**
* Constructor method to start up a Receiver server. Reads configuration file, options, and
@ -70,7 +70,9 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success){
case 'f':
fname = optarg;
//cout << long_options[option_index].name << " " << optarg << endl;
#ifdef VERYVERBOSE
FILE_LOG(logDEBUG) << long_options[option_index].name << " " << optarg << endl;
#endif
break;
case 'b':
@ -94,7 +96,7 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success){
help_message += """\t--type:\t Type of the receiver. Possible arguments are: standard, REST. Default: standard.\n\n""";
cout << help_message << endl;
FILE_LOG(logINFO) << help_message << endl;
break;
}

View File

@ -70,7 +70,7 @@ slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int &success, UDPInterface*
strcpy(mess,"dummy message");
function_table();
#ifdef VERYVERBOSE
cout << "Function table assigned." << endl;
FILE_LOG(logINFO) << "Function table assigned.";
#endif
}
}
@ -89,7 +89,7 @@ int slsReceiverTCPIPInterface::setPortNumber(int pn){
if (p_number<1024) {
sprintf(mess,"Too low port number %d\n", p_number);
cout << mess << endl;
bprintf(RED,"%s",mess);
} else {
oldsocket=mySock;
@ -101,10 +101,9 @@ int slsReceiverTCPIPInterface::setPortNumber(int pn){
strcpy(mySock->lastClientIP,oldsocket->lastClientIP);
delete oldsocket;
} else {
cout << "Could not bind port " << p_number << endl;
FILE_LOG(logERROR) << "Could not bind port " << p_number;
if (sd==-10) {
cout << "Port "<< p_number << " already set" << endl;
FILE_LOG(logINFO) << "Port "<< p_number << " already set";
} else {
delete mySock;
mySock=oldsocket;
@ -123,27 +122,26 @@ int slsReceiverTCPIPInterface::setPortNumber(int pn){
int slsReceiverTCPIPInterface::start(){
FILE_LOG(logDEBUG) << "Creating TCP Server Thread" << endl;
FILE_LOG(logDEBUG) << "Creating TCP Server Thread";
killTCPServerThread = 0;
if(pthread_create(&TCPServer_thread, NULL,startTCPServerThread, (void*) this)){
cout << "Could not create TCP Server thread" << endl;
FILE_LOG(logERROR) << "Could not create TCP Server thread";
return FAIL;
}
//#ifdef VERYVERBOSE
FILE_LOG(logDEBUG) << "TCP Server thread created successfully." << endl;
FILE_LOG(logDEBUG) << "TCP Server thread created successfully.";
//#endif
return OK;
}
void slsReceiverTCPIPInterface::stop(){
cout << "Shutting down UDP Socket" << endl;
FILE_LOG(logINFO) << "Shutting down UDP Socket";
killTCPServerThread = 1;
if(mySock) mySock->ShutDownSocket();
cout<<"Socket closed"<<endl;
FILE_LOG(logDEBUG) << "Socket closed";
pthread_join(TCPServer_thread, NULL);
killTCPServerThread = 0;
cout<<"Threads joined"<<endl;
}
@ -160,38 +158,38 @@ void slsReceiverTCPIPInterface::startTCPServer(){
#ifdef VERYVERBOSE
cout << "Starting Receiver TCP Server" << endl;
FILE_LOG(logDEBUG5) << "Starting Receiver TCP Server";
#endif
int v=OK;
while(1) {
#ifdef VERYVERBOSE
cout<< endl;
FILE_LOG(logDEBUG5);
#endif
#ifdef VERY_VERBOSE
cout << "Waiting for client call" << endl;
FILE_LOG(logDEBUG5) << "Waiting for client call";
#endif
if(mySock->Connect()>=0){
#ifdef VERY_VERBOSE
cout << "Conenction accepted" << endl;
FILE_LOG(logDEBUG5) << "Conenction accepted";
#endif
v = decode_function();
#ifdef VERY_VERBOSE
cout << "function executed" << endl;
FILE_LOG(logDEBUG5) << "function executed";
#endif
mySock->Disconnect();
#ifdef VERY_VERBOSE
cout << "connection closed" << endl;
FILE_LOG(logDEBUG5) << "connection closed";
#endif
}
//if tcp command was to exit server
if(v==GOODBYE){
cout << "Shutting down UDP Socket" << endl;
FILE_LOG(logINFO) << "Shutting down UDP Socket";
if(receiverBase){
receiverBase->shutDownUDPSockets();
cout << "Closing Files... " << endl;
FILE_LOG(logINFO) << "Closing Files... ";
receiverBase->closeFiles();
}
@ -269,7 +267,7 @@ int slsReceiverTCPIPInterface::function_table(){
#ifdef VERYVERBOSE
for (int i=0;i<numberOfFunctions;i++)
cout << "function " << i << "located at " << flist[i] << endl;
FILE_LOG(logDEBUG1) << "function " << i << "located at " << flist[i];
#endif
return OK;
@ -283,22 +281,22 @@ int slsReceiverTCPIPInterface::decode_function(){
ret = FAIL;
int n,fnum;
#ifdef VERYVERBOSE
cout << "receive data" << endl;
FILE_LOG(logDEBUG1) << "receive data";
#endif
n = mySock->ReceiveDataOnly(&fnum,sizeof(fnum));
if (n <= 0) {
#ifdef VERYVERBOSE
cout << "ERROR reading from socket " << n << ", " << fnum << endl;
FILE_LOG(logDEBUG1) << "ERROR reading from socket " << n << ", " << fnum;
#endif
return FAIL;
}
#ifdef VERYVERBOSE
else
cout << "size of data received " << n <<endl;
FILE_LOG(logDEBUG1) << "size of data received " << n;
#endif
#ifdef VERYVERBOSE
cout << "calling function fnum = "<< fnum << dec << ":"<< flist[fnum] << endl;
FILE_LOG(logDEBUG1) << "calling function fnum = "<< fnum << dec << ":"<< flist[fnum];
#endif
if (fnum<0 || fnum>numberOfFunctions-1)
@ -306,7 +304,7 @@ int slsReceiverTCPIPInterface::decode_function(){
//calling function
(this->*flist[fnum])();
if (ret==FAIL)
cprintf(RED, "Error executing the function = %d\n",fnum);
bprintf(RED, "Error executing the function = %d\n",fnum);
return ret;
}
@ -320,7 +318,7 @@ int slsReceiverTCPIPInterface::M_nofunc(){
ret=FAIL;
sprintf(mess,"Unrecognized Function\n");
cout << mess << endl;
FILE_LOG(logERROR) << mess;
mySock->SendDataOnly(&ret,sizeof(ret));
mySock->SendDataOnly(mess,sizeof(mess));
@ -358,7 +356,7 @@ int slsReceiverTCPIPInterface::set_detector_type(){
}
else if((receiverBase)&&(receiverBase->getStatus()!= IDLE)){
strcpy(mess,"Can not set detector type while receiver not idle\n");
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret = FAIL;
}
else{
@ -399,7 +397,7 @@ int slsReceiverTCPIPInterface::set_detector_type(){
if(ret!=FAIL)
FILE_LOG(logDEBUG) << "detector type " << dr;
else
cprintf(RED, "%s\n", mess);
bprintf(RED, "%s\n", mess);
//#endif
#endif
@ -451,7 +449,7 @@ int slsReceiverTCPIPInterface::set_file_name() {
}
else if(receiverBase->getStatus()!= IDLE){
strcpy(mess,"Can not set file name while receiver not idle\n");
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret = FAIL;
}
else{
@ -463,9 +461,9 @@ int slsReceiverTCPIPInterface::set_file_name() {
}
#ifdef VERYVERBOSE
if(ret!=FAIL)
cout << "file name:" << retval << endl;
FILE_LOG(logDEBUG1) << "file name:" << retval;
else
cout << mess << endl;
FILE_LOG(logERROR) << mess;
#endif
#endif
@ -478,7 +476,7 @@ int slsReceiverTCPIPInterface::set_file_name() {
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED, "%s\n", mess);
bprintf(RED, "%s\n", mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
if(retval == NULL)
@ -524,7 +522,7 @@ int slsReceiverTCPIPInterface::set_file_dir() {
}
else if(receiverBase->getStatus()!= IDLE){
strcpy(mess,"Can not set file path while receiver not idle\n");
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret = FAIL;
}
else{
@ -539,9 +537,9 @@ int slsReceiverTCPIPInterface::set_file_dir() {
}
#ifdef VERYVERBOSE
if(ret!=FAIL)
cout << "file path:" << retval << endl;
FILE_LOG(logDEBUG1) << "file path:" << retval;
else
cout << mess << endl;
FILE_LOG(logERROR) << mess;
#endif
#endif
@ -553,7 +551,7 @@ int slsReceiverTCPIPInterface::set_file_dir() {
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED, "%s\n", mess);
bprintf(RED, "%s\n", mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
if(retval == NULL)
@ -598,7 +596,7 @@ int slsReceiverTCPIPInterface::set_file_index() {
}
else if(receiverBase->getStatus()!= IDLE){
strcpy(mess,"Can not set file index while receiver not idle\n");
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret = FAIL;
}
else{
@ -611,9 +609,9 @@ int slsReceiverTCPIPInterface::set_file_index() {
}
#ifdef VERYVERBOSE
if(ret!=FAIL)
cout << "file index:" << retval << endl;
FILE_LOG(logDEBUG1) << "file index:" << retval;
else
cout << mess << endl;
FILE_LOG(logERROR) << mess;
#endif
#endif
@ -625,7 +623,7 @@ int slsReceiverTCPIPInterface::set_file_index() {
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED, "%s\n", mess);
bprintf(RED, "%s\n", mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
mySock->SendDataOnly(&retval,sizeof(retval));
@ -667,7 +665,7 @@ int slsReceiverTCPIPInterface::set_frame_index() {
}
else if(receiverBase->getStatus()!= IDLE){
strcpy(mess,"Can not set frame index while receiver not idle\n");
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret = FAIL;
}
else{
@ -689,9 +687,9 @@ int slsReceiverTCPIPInterface::set_frame_index() {
}
#ifdef VERYVERBOSE
if(ret!=FAIL)
cout << "frame index:" << retval << endl;
FILE_LOG(logDEBUG1) << "frame index:" << retval;
else
cout << mess << endl;
FILE_LOG(logERROR) << mess;
#endif
#endif
@ -703,7 +701,7 @@ int slsReceiverTCPIPInterface::set_frame_index() {
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED, "%s\n", mess);
bprintf(RED, "%s\n", mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
mySock->SendDataOnly(&retval,sizeof(retval));
@ -749,7 +747,7 @@ int slsReceiverTCPIPInterface::setup_udp(){
}
else if(receiverBase->getStatus()!= IDLE){
strcpy(mess,"Can not set up udp while receiver not idle\n");
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret = FAIL;
}
else{
@ -844,7 +842,7 @@ int slsReceiverTCPIPInterface::start_receiver(){
ret=receiverBase->startReceiver(mess);
else{
sprintf(mess,"Cannot start Receiver as it is in %s state\n",runStatusType(s).c_str());
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret=FAIL;
}
}
@ -858,7 +856,7 @@ int slsReceiverTCPIPInterface::start_receiver(){
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED, "Error:%s\n", mess);
bprintf(RED, "Error:%s\n", mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
//return ok/fail
@ -892,7 +890,7 @@ int slsReceiverTCPIPInterface::stop_receiver(){
ret = OK;
else{
sprintf(mess,"Could not stop receiver. It is in %s state\n",runStatusType(s).c_str());
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret = FAIL;
}
}
@ -906,7 +904,7 @@ int slsReceiverTCPIPInterface::stop_receiver(){
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED, "%s\n", mess);
bprintf(RED, "%s\n", mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
//return ok/fail
@ -937,7 +935,7 @@ int slsReceiverTCPIPInterface::get_status(){
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED, "%s\n", mess);
bprintf(RED, "%s\n", mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
retval = (runStatus(s));
@ -968,7 +966,7 @@ int slsReceiverTCPIPInterface::get_frames_caught(){
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED, "%s\n", mess);
bprintf(RED, "%s\n", mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
mySock->SendDataOnly(&retval,sizeof(retval));
@ -1000,7 +998,7 @@ int slsReceiverTCPIPInterface::get_frame_index(){
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED, "%s\n", mess);
bprintf(RED, "%s\n", mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
mySock->SendDataOnly(&retval,sizeof(retval));
@ -1045,7 +1043,7 @@ int slsReceiverTCPIPInterface::reset_frames_caught(){
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED, "%s\n", mess);
bprintf(RED, "%s\n", mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
//return ok/fail
@ -1091,7 +1089,7 @@ int slsReceiverTCPIPInterface::set_short_frame() {
}
else if(receiverBase->getStatus()!= IDLE){
strcpy(mess,"Cannot set short frame while status is running\n");
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret=FAIL;
}
else{
@ -1109,7 +1107,7 @@ int slsReceiverTCPIPInterface::set_short_frame() {
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED, "%s\n", mess);
bprintf(RED, "%s\n", mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
mySock->SendDataOnly(&retval,sizeof(retval));
@ -1203,7 +1201,7 @@ int slsReceiverTCPIPInterface::set_read_frequency(){
}
else if(receiverBase->getStatus()!= IDLE){
strcpy(mess,"Can not set receiver frequency mode while receiver not idle\n");
cprintf(RED,"%s\n",mess);
bprintf(RED,"%s\n",mess);
ret = FAIL;
}
else{
@ -1211,13 +1209,13 @@ int slsReceiverTCPIPInterface::set_read_frequency(){
ret = receiverBase->setFrameToGuiFrequency(index);
if(ret == FAIL){
strcpy(mess, "Could not allocate memory for listening fifo\n");
cprintf(RED,"%s\n",mess);
bprintf(RED,"%s\n",mess);
}
}
retval=receiverBase->getFrameToGuiFrequency();
if(index>=0 && retval!=index){
strcpy(mess,"Could not set frame to gui frequency");
cprintf(RED,"%s\n",mess);
bprintf(RED,"%s\n",mess);
ret = FAIL;
}
}
@ -1233,7 +1231,7 @@ int slsReceiverTCPIPInterface::set_read_frequency(){
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED,"%s\n",mess);
bprintf(RED,"%s\n",mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
mySock->SendDataOnly(&retval,sizeof(retval));
@ -1273,7 +1271,7 @@ int slsReceiverTCPIPInterface::set_read_receiver_timer(){
}
else if(receiverBase->getStatus()!= IDLE){
strcpy(mess,"Can not set receiver frequency mode while receiver not idle\n");
cprintf(RED,"%s\n",mess);
bprintf(RED,"%s\n",mess);
ret = FAIL;
}
else{
@ -1283,7 +1281,7 @@ int slsReceiverTCPIPInterface::set_read_receiver_timer(){
retval=receiverBase->getFrameToGuiTimer();
if(index>=0 && retval!=index){
strcpy(mess,"Could not set datastream timer");
cprintf(RED,"%s\n",mess);
bprintf(RED,"%s\n",mess);
ret = FAIL;
}
}
@ -1299,7 +1297,7 @@ int slsReceiverTCPIPInterface::set_read_receiver_timer(){
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED,"%s\n",mess);
bprintf(RED,"%s\n",mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
mySock->SendDataOnly(&retval,sizeof(retval));
@ -1337,7 +1335,7 @@ int slsReceiverTCPIPInterface::set_data_stream_enable(){
}
else if((index >= 0) && (receiverBase->getStatus()!= IDLE)){
strcpy(mess,"Can not set data stream enable while receiver not idle\n");
cprintf(RED,"%s\n",mess);
bprintf(RED,"%s\n",mess);
ret = FAIL;
}
else{
@ -1346,7 +1344,7 @@ int slsReceiverTCPIPInterface::set_data_stream_enable(){
retval=receiverBase->getDataStreamEnable();
if(index>=0 && retval!=index){
strcpy(mess,"Could not set data stream enable");
cprintf(RED,"%s\n",mess);
bprintf(RED,"%s\n",mess);
ret = FAIL;
}
}
@ -1362,7 +1360,7 @@ int slsReceiverTCPIPInterface::set_data_stream_enable(){
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED,"%s\n",mess);
bprintf(RED,"%s\n",mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
mySock->SendDataOnly(&retval,sizeof(retval));
@ -1401,7 +1399,7 @@ int slsReceiverTCPIPInterface::enable_file_write(){
}
else if(receiverBase->getStatus()!= IDLE){
strcpy(mess,"Can not set file write mode while receiver not idle\n");
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret = FAIL;
}
else{
@ -1422,7 +1420,7 @@ int slsReceiverTCPIPInterface::enable_file_write(){
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED,"%s\n",mess);
bprintf(RED,"%s\n",mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
mySock->SendDataOnly(&retval,sizeof(retval));
@ -1466,7 +1464,7 @@ int64_t slsReceiverTCPIPInterface::getReceiverVersion(){
int slsReceiverTCPIPInterface::start_readout(){cprintf(BLUE,"In start readout!\n");
int slsReceiverTCPIPInterface::start_readout(){bprintf(BLUE,"In start readout!\n");
ret=OK;
enum runStatus retval;
@ -1498,7 +1496,7 @@ int slsReceiverTCPIPInterface::start_readout(){cprintf(BLUE,"In start readout!\n
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED,"%s\n",mess);
bprintf(RED,"%s\n",mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
mySock->SendDataOnly(&retval,sizeof(retval));
@ -1538,7 +1536,7 @@ int slsReceiverTCPIPInterface::set_timer() {
}
else if(receiverBase->getStatus()!= IDLE){
strcpy(mess,"Can not set timer while receiver not idle\n");
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret = FAIL;
}
else{
@ -1568,13 +1566,13 @@ int slsReceiverTCPIPInterface::set_timer() {
#ifdef VERYVERBOSE
if(ret!=FAIL){
if(index[0] == ACQUISITION_TIME)
cout << "acquisition time:" << retval << endl;
FILE_LOG(logDEBUG1) << "acquisition time:" << retval;
else if(index[0] == FRAME_PERIOD)
cout << "acquisition period:" << retval << endl;
FILE_LOG(logDEBUG1) << "acquisition period:" << retval
else
cout << "frame number:" << retval << endl;
FILE_LOG(logDEBUG1) << "frame number:" << retval;
}else
cout << mess << endl;
FILE_LOG(logERROR) << mess;
#endif
#endif
@ -1586,7 +1584,7 @@ int slsReceiverTCPIPInterface::set_timer() {
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED,"%s\n",mess);
bprintf(RED,"%s\n",mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
mySock->SendDataOnly(&retval,sizeof(retval));
@ -1627,7 +1625,7 @@ int slsReceiverTCPIPInterface::enable_compression() {
}
else if(receiverBase->getStatus()!= IDLE){
strcpy(mess,"Cannot enable/disable compression while status is running\n");
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret=FAIL;
}
else{
@ -1658,7 +1656,7 @@ int slsReceiverTCPIPInterface::enable_compression() {
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED,"%s\n",mess);
bprintf(RED,"%s\n",mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
mySock->SendDataOnly(&retval,sizeof(retval));
@ -1697,7 +1695,7 @@ int slsReceiverTCPIPInterface::set_detector_hostname() {
}
else if(receiverBase->getStatus()!= IDLE){
strcpy(mess,"Can not set detector hostname while receiver not idle\n");
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret = FAIL;
}
else{
@ -1710,9 +1708,9 @@ int slsReceiverTCPIPInterface::set_detector_hostname() {
}
#ifdef VERYVERBOSE
if(ret!=FAIL)
cout << "hostname:" << retval << endl;
FILE_LOG(logDEBUG1) << "hostname:" << retval;
else
cout << mess << endl;
FILE_LOG(logERROR) << mess;
#endif
#endif
@ -1724,7 +1722,7 @@ int slsReceiverTCPIPInterface::set_detector_hostname() {
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED, "%s\n", mess);
bprintf(RED, "%s\n", mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
if(retval == NULL)
@ -1772,7 +1770,7 @@ int slsReceiverTCPIPInterface::set_dynamic_range() {
case 32:break;
default:
sprintf(mess,"This dynamic range does not exist: %d\n",dr);
cprintf(RED,"%s", mess);
bprintf(RED,"%s", mess);
ret=FAIL;
break;
}
@ -1784,7 +1782,7 @@ int slsReceiverTCPIPInterface::set_dynamic_range() {
}
else if(receiverBase->getStatus()!= IDLE){
strcpy(mess,"Can not set dynamic range while receiver not idle\n");
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret = FAIL;
}
else{
@ -1801,9 +1799,9 @@ int slsReceiverTCPIPInterface::set_dynamic_range() {
}
#ifdef VERYVERBOSE
if(ret!=FAIL)
cout << "dynamic range" << dr << endl;
FILE_LOG(logDEBUG1) << "dynamic range" << dr;
else
cout << mess << endl;
FILE_LOG(logERROR) << mess;
#endif
#endif
@ -1815,7 +1813,7 @@ int slsReceiverTCPIPInterface::set_dynamic_range() {
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED,"%s\n",mess);
bprintf(RED,"%s\n",mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
mySock->SendDataOnly(&retval,sizeof(retval));
@ -1856,7 +1854,7 @@ int slsReceiverTCPIPInterface::enable_overwrite() {
}
else if(receiverBase->getStatus()!= IDLE){
strcpy(mess,"Can not set overwrite mode while receiver not idle\n");
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret = FAIL;
}
else{
@ -1869,9 +1867,9 @@ int slsReceiverTCPIPInterface::enable_overwrite() {
}
#ifdef VERYVERBOSE
if(ret!=FAIL)
cout << "overwrite:" << retval << endl;
FILE_LOG(logDEBUG1) << "overwrite:" << retval;
else
cout << mess << endl;
FILE_LOG(logERROR) << mess;
#endif
#endif
@ -1883,7 +1881,7 @@ int slsReceiverTCPIPInterface::enable_overwrite() {
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED,"%s\n",mess);
bprintf(RED,"%s\n",mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
mySock->SendDataOnly(&retval,sizeof(retval));
@ -1924,7 +1922,7 @@ int slsReceiverTCPIPInterface::enable_tengiga() {
}
else if(receiverBase->getStatus()!= IDLE){
strcpy(mess,"Can not set up 1Giga/10Giga mode while receiver not idle\n");
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret = FAIL;
}
else{
@ -1939,9 +1937,9 @@ int slsReceiverTCPIPInterface::enable_tengiga() {
}
#ifdef VERYVERBOSE
if(ret!=FAIL)
cout << "10Gbe:" << val << endl;
FILE_LOG(logDEBUG1) << "10Gbe:" << val;
else
cout << mess << endl;
FILE_LOG(logDEBUG1) << mess;
#endif
#endif
@ -1953,7 +1951,7 @@ int slsReceiverTCPIPInterface::enable_tengiga() {
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED,"%s\n",mess);
bprintf(RED,"%s\n",mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
mySock->SendDataOnly(&retval,sizeof(retval));
@ -1994,7 +1992,7 @@ int slsReceiverTCPIPInterface::set_fifo_depth() {
}
else if(receiverBase->getStatus()!= IDLE){
strcpy(mess,"Cannot set/get fifo depth while status is running\n");
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret=FAIL;
}
else{
@ -2025,7 +2023,7 @@ int slsReceiverTCPIPInterface::set_fifo_depth() {
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED,"%s\n",mess);
bprintf(RED,"%s\n",mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
mySock->SendDataOnly(&retval,sizeof(retval));
@ -2048,7 +2046,7 @@ int slsReceiverTCPIPInterface::set_activate() {
// receive arguments
if(mySock->ReceiveDataOnly(&enable,sizeof(enable)) < 0 ){
strcpy(mess,"Error reading from socket\n");
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret = FAIL;
}
@ -2064,11 +2062,11 @@ int slsReceiverTCPIPInterface::set_activate() {
if(ret!=FAIL){
if (receiverBase == NULL){
strcpy(mess,SET_RECEIVER_ERR_MESSAGE);
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret=FAIL;
}else if(receiverBase->getStatus()==RUNNING){
strcpy(mess,"Cannot activate/deactivate while status is running\n");
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret=FAIL;
}else{
if(enable != -1)
@ -2077,7 +2075,7 @@ int slsReceiverTCPIPInterface::set_activate() {
if(enable >= 0 && retval != enable){
sprintf(mess,"Tried to set activate to %d, but returned %d\n",enable,retval);
ret = FAIL;
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
}
}
}
@ -2085,9 +2083,9 @@ int slsReceiverTCPIPInterface::set_activate() {
#endif
#ifdef VERYVERBOSE
if(ret!=FAIL)
cout << "Activate: " << retval << endl;
FILE_LOG(logDEBUG1) << "Activate: " << retval;
else
cout << mess << endl;
FILE_LOG(logDEBUG1) << mess;
#endif
@ -2099,7 +2097,7 @@ int slsReceiverTCPIPInterface::set_activate() {
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED,"%s\n",mess);
bprintf(RED,"%s\n",mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
mySock->SendDataOnly(&retval,sizeof(retval));
@ -2138,7 +2136,7 @@ int slsReceiverTCPIPInterface::set_flipped_data(){
}
else if(receiverBase->getStatus()!= IDLE){
strcpy(mess,"Can not set flipped data while receiver not idle\n");
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret = FAIL;
}
else{
@ -2149,9 +2147,9 @@ int slsReceiverTCPIPInterface::set_flipped_data(){
}
#ifdef VERYVERBOSE
if(ret!=FAIL){
cout << "Flipped Data:" << retval << endl;
FILE_LOG(logDEBUG1) << "Flipped Data:" << retval;
}else
cout << mess << endl;
FILE_LOG(logDEBUG1) << mess;
#endif
#endif
@ -2163,7 +2161,7 @@ int slsReceiverTCPIPInterface::set_flipped_data(){
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED,"%s\n",mess);
bprintf(RED,"%s\n",mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
mySock->SendDataOnly(&retval,sizeof(retval));
@ -2185,7 +2183,7 @@ int slsReceiverTCPIPInterface::set_file_format() {
// receive arguments
if(mySock->ReceiveDataOnly(&f,sizeof(f)) < 0 ){
strcpy(mess,"Error reading from socket\n");
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret = FAIL;
}
@ -2201,11 +2199,11 @@ int slsReceiverTCPIPInterface::set_file_format() {
if(ret!=FAIL){
if (receiverBase == NULL){
strcpy(mess,SET_RECEIVER_ERR_MESSAGE);
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret=FAIL;
}else if(receiverBase->getStatus()==RUNNING && (f>=0)){
strcpy(mess,"Cannot set file format while status is running\n");
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret=FAIL;
}else{
if(f != -1)
@ -2214,7 +2212,7 @@ int slsReceiverTCPIPInterface::set_file_format() {
if(f >= 0 && retval != f){
sprintf(mess,"Tried to set file format to %d, but returned %d\n",f,retval);
ret = FAIL;
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
}
}
}
@ -2222,9 +2220,9 @@ int slsReceiverTCPIPInterface::set_file_format() {
#endif
#ifdef VERYVERBOSE
if(ret!=FAIL)
cout << "File Format: " << retval << endl;
FILE_LOG(logDEBUG1) << "File Format: " << retval;
else
cout << mess << endl;
FILE_LOG(logDEBUG1) << mess;
#endif
@ -2236,7 +2234,7 @@ int slsReceiverTCPIPInterface::set_file_format() {
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED,"%s\n",mess);
bprintf(RED,"%s\n",mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
mySock->SendDataOnly(&retval,sizeof(retval));
@ -2274,7 +2272,7 @@ int slsReceiverTCPIPInterface::set_detector_posid() {
}
else if(receiverBase->getStatus()!= IDLE){
strcpy(mess,"Can not set position file id while receiver not idle\n");
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret = FAIL;
}
else{
@ -2287,9 +2285,9 @@ int slsReceiverTCPIPInterface::set_detector_posid() {
}
#ifdef VERYVERBOSE
if(ret!=FAIL)
cout << "Position Id:" << retval << endl;
FILE_LOG(logDEBUG1) << "Position Id:" << retval;
else
cout << mess << endl;
FILE_LOG(logDEBUG1) << mess;
#endif
#endif
@ -2301,7 +2299,7 @@ int slsReceiverTCPIPInterface::set_detector_posid() {
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED, "%s\n", mess);
bprintf(RED, "%s\n", mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
mySock->SendDataOnly(&retval,sizeof(retval));
@ -2340,11 +2338,11 @@ int slsReceiverTCPIPInterface::set_multi_detector_size() {
else if (receiverBase == NULL){
strcpy(mess,SET_RECEIVER_ERR_MESSAGE);
ret=FAIL;
cprintf(RED, "%s", mess);
bprintf(RED, "%s", mess);
}
else if(receiverBase->getStatus()!= IDLE){
strcpy(mess,"Can not set position file id while receiver not idle\n");
cprintf(RED,"%s",mess);
bprintf(RED,"%s",mess);
ret = FAIL;
}
else{
@ -2354,9 +2352,9 @@ int slsReceiverTCPIPInterface::set_multi_detector_size() {
}
#ifdef VERYVERBOSE
if(ret!=FAIL)
cout << "Multi Detector Size:" << retval << endl;
FILE_LOG(logDEBUG1) << "Multi Detector Size:" << retval;
else
cout << mess << endl;
FILE_LOG(logDEBUG1) << mess;
#endif
#endif
@ -2368,7 +2366,7 @@ int slsReceiverTCPIPInterface::set_multi_detector_size() {
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED, "%s\n", mess);
bprintf(RED, "%s\n", mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
mySock->SendDataOnly(&retval,sizeof(retval));
@ -2410,7 +2408,7 @@ int slsReceiverTCPIPInterface::lock_receiver() {
// receive arguments
if(mySock->ReceiveDataOnly(&lock,sizeof(lock)) < 0 ){
sprintf(mess,"Error reading from socket\n");
cout << "Error reading from socket (lock)" << endl;
FILE_LOG(logERROR) << "Error reading from socket (lock)";
ret=FAIL;
}
// execute action if the arguments correctly arrived
@ -2432,7 +2430,7 @@ int slsReceiverTCPIPInterface::lock_receiver() {
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED,"%s\n",mess);
bprintf(RED,"%s\n",mess);
mySock->SendDataOnly(mess,sizeof(mess));
}
else
@ -2459,13 +2457,12 @@ int slsReceiverTCPIPInterface::set_port() {
// receive arguments
if(mySock->ReceiveDataOnly(&p_type,sizeof(p_type)) < 0 ){
strcpy(mess,"Error reading from socket\n");
cout << mess << endl;
FILE_LOG(logERROR) << mess;
ret=FAIL;
}
if(mySock->ReceiveDataOnly(&p_number,sizeof(p_number)) < 0 ){
strcpy(mess,"Error reading from socket\n");
cout << mess << endl;
FILE_LOG(logERROR) << mess;
ret=FAIL;
}
@ -2478,10 +2475,10 @@ int slsReceiverTCPIPInterface::set_port() {
else {
if (p_number<1024) {
sprintf(mess,"Too low port number %d\n", p_number);
cout << mess << endl;
FILE_LOG(logERROR) << mess;
ret=FAIL;
}
cout << "set port " << p_type << " to " << p_number <<endl;
FILE_LOG(logINFO) << "set port " << p_type << " to " << p_number <<endl;
strcpy(oldLastClientIP, mySock->lastClientIP);
mySocket = new MySocketTCP(p_number);
}
@ -2495,10 +2492,10 @@ int slsReceiverTCPIPInterface::set_port() {
} else {
ret=FAIL;
sprintf(mess,"Could not bind port %d\n", p_number);
cout << mess << endl;
FILE_LOG(logERROR) << mess;
if (sd==-10) {
sprintf(mess,"Port %d already set\n", p_number);
cout << mess << endl;
FILE_LOG(logERROR) << mess;
}
}
}
@ -2507,7 +2504,7 @@ int slsReceiverTCPIPInterface::set_port() {
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED,"%s\n",mess);
bprintf(RED,"%s\n",mess);
mySock->SendDataOnly(mess,sizeof(mess));
}else {
mySock->SendDataOnly(&p_number,sizeof(p_number));
@ -2606,7 +2603,7 @@ int slsReceiverTCPIPInterface::update_client() {
}
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED,"%s\n",mess);
bprintf(RED,"%s\n",mess);
mySock->SendDataOnly(mess,sizeof(mess));
return ret;
}
@ -2625,7 +2622,7 @@ int slsReceiverTCPIPInterface::exit_server() {
mySock->SendDataOnly(&ret,sizeof(ret));
strcpy(mess,"closing server");
mySock->SendDataOnly(mess,sizeof(mess));
cprintf(RED,"%s\n",mess);
bprintf(RED,"%s\n",mess);
return ret;
}
@ -2648,7 +2645,7 @@ int slsReceiverTCPIPInterface::exec_command() {
// execute action if the arguments correctly arrived
if (ret==OK) {
#ifdef VERYVERBOSE
cout << "executing command " << cmd << endl;
FILE_LOG(logDEBUG5) << "executing command " << cmd;
#endif
if (lockStatus==0 || mySock->differentClients==0)
sysret=system(cmd);

View File

@ -54,9 +54,9 @@ int read_config_file(string fname, int *tcpip_port_no, map<string, string> * con
if(sstr.good()) {
sstr >> sargname;
if(sscanf(sargname.c_str(),"%d",tcpip_port_no))
cout<<"dataport:"<<tcpip_port_no<<endl;
bprintf(GRAY, "dataport: %d\n" , *tcpip_port_no);
else{
cout << "could not decode port in config file. Exiting." << endl;
bprintf(RED, "could not decode port in config file. Exiting.\n");
success = slsReceiverDefs::FAIL;
}
}