This commit is contained in:
Dhanya Maliakal
2015-10-29 17:23:39 +01:00
parent 9b449009ff
commit 963717215f
6 changed files with 221 additions and 203 deletions

View File

@ -4,6 +4,7 @@
#define BLUE "\x1b[34m"
#define MAGENTA "\x1b[35m"
#define CYAN "\x1b[36m"
#define GRAY "\x1b[37m"
#define BG_RED "\x1b[41m"
#define BG_GREEN "\x1b[42m"
#define BG_YELLOW "\x1b[43m"

View File

@ -5,6 +5,7 @@
#include <string>
#include <stdio.h>
#include <unistd.h>
#include <ansi.h>
#ifdef VERBOSE
#define FILELOG_MAX_LEVEL logDEBUG
@ -14,6 +15,10 @@
#define FILELOG_MAX_LEVEL logDEBUG4
#endif
#ifdef FIFODEBUG
#define FILELOG_MAX_LEVEL logDEBUG5
#endif
#ifndef FILELOG_MAX_LEVEL
#define FILELOG_MAX_LEVEL logINFO
#endif
@ -40,7 +45,7 @@ void error(const char *location, const char *msg){
inline std::string NowTime();
enum TLogLevel {logERROR, logWARNING, logINFO, logDEBUG, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4};
enum TLogLevel {logERROR, logWARNING, logINFO, logDEBUG, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4, logDEBUG5};
template <typename T> class Log{
public:
@ -52,6 +57,7 @@ template <typename T> class Log{
static TLogLevel FromString(const std::string& level);
protected:
std::ostringstream os;
TLogLevel lev;
private:
Log(const Log&);
Log& operator =(const Log&);
@ -62,6 +68,7 @@ class Output2FILE {
public:
static FILE*& Stream();
static void Output(const std::string& msg);
static void Output(const std::string& msg, TLogLevel level);
};
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
@ -79,10 +86,17 @@ public:
class FILELOG_DECLSPEC FILELog : public Log<Output2FILE> {};
//typedef Log<Output2FILE> FILELog;
#ifdef REST
#define FILE_LOG(level) \
if (level > FILELOG_MAX_LEVEL) ; \
else if (level > FILELog::ReportingLevel() || !Output2FILE::Stream()) ; \
else FILELog().Get(level)
#else
#define FILE_LOG(level) \
if (level > FILELOG_MAX_LEVEL) ; \
else if (level > FILELog::ReportingLevel() || !Output2FILE::Stream()) ; \
else FILELog().Get(level)
#endif
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
@ -126,10 +140,11 @@ inline std::string NowTime()
#endif //WIN32
template <typename T> Log<T>::Log(){}
template <typename T> Log<T>::Log():lev(logDEBUG){}
template <typename T> std::ostringstream& Log<T>::Get(TLogLevel level)
{
lev = level;
os << "- " << NowTime();
os << " " << ToString(level) << ": ";
os << std::string(level > logDEBUG ? level - logDEBUG : 0, '\t');
@ -139,24 +154,30 @@ template <typename T> std::ostringstream& Log<T>::Get(TLogLevel level)
template <typename T> Log<T>::~Log()
{
os << std::endl;
#ifdef REST
T::Output( os.str());
#else
T::Output( os.str(),lev);
#endif
}
template <typename T> TLogLevel& Log<T>::ReportingLevel()
{
static TLogLevel reportingLevel = logDEBUG4;
static TLogLevel reportingLevel = logDEBUG5;
return reportingLevel;
}
template <typename T> std::string Log<T>::ToString(TLogLevel level)
{
static const char* const buffer[] = {"ERROR", "WARNING", "INFO", "DEBUG", "DEBUG1", "DEBUG2", "DEBUG3", "DEBUG4"};
static const char* const buffer[] = {"ERROR", "WARNING", "INFO", "DEBUG", "DEBUG1", "DEBUG2", "DEBUG3", "DEBUG4","DEBUG5"};
return buffer[level];
}
template <typename T>
TLogLevel Log<T>::FromString(const std::string& level)
{
if (level == "DEBUG5")
return logDEBUG5;
if (level == "DEBUG4")
return logDEBUG4;
if (level == "DEBUG3")
@ -193,6 +214,20 @@ inline void Output2FILE::Output(const std::string& msg)
fflush(pStream);
}
inline void Output2FILE::Output(const std::string& msg, TLogLevel level)
{
FILE* pStream = Stream();
if (!pStream)
return;
switch(level){
case logERROR: cprintf(RED BOLD,"%s",msg.c_str()); break;
case logWARNING: cprintf(YELLOW BOLD,"%s",msg.c_str()); break;
case logINFO: cprintf(GRAY,"%s",msg.c_str()); break;
default: fprintf(pStream,"%s",msg.c_str()); break;
}
fflush(pStream);
}
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
# if defined (BUILDING_FILELOG_DLL)
# define FILELOG_DECLSPEC __declspec (dllexport)

View File

@ -35,7 +35,7 @@ UDPBaseImplementation::UDPBaseImplementation(){
void UDPBaseImplementation::initializeMembers(){
FILE_LOG(logDEBUG) << __AT__ << " starting";
FILE_LOG(logDEBUG1) << "Info: Initializing base members" << endl;
FILE_LOG(logDEBUG) << "Info: Initializing base members";
//**detector parameters***
myDetectorType = GENERIC;
strcpy(detHostname,"");
@ -202,7 +202,7 @@ void UDPBaseImplementation::setBottomEnable(const bool b){
FILE_LOG(logDEBUG) << __AT__ << " starting";
bottomEnable = b;
FILE_LOG(logINFO) << "Bottom - " << stringEnable(bottomEnable) << endl;
FILE_LOG(logINFO) << "Bottom - " << stringEnable(bottomEnable);
}
@ -216,7 +216,7 @@ void UDPBaseImplementation::setFileName(const char c[]){
}
void UDPBaseImplementation::setFilePath(const char c[]){
FILE_LOG(logINFO) << __AT__ << " starting";
FILE_LOG(logDEBUG) << __AT__ << " starting";
if(strlen(c)){
//check if filepath exists
@ -229,7 +229,7 @@ void UDPBaseImplementation::setFilePath(const char c[]){
}
strcpy(filePath, c);
}
FILE_LOG(logDEBUG1) << "Info: File path:" << filePath;
FILE_LOG(logDEBUG) << "Info: File path:" << filePath;
}
void UDPBaseImplementation::setFileIndex(const uint64_t i){
@ -285,14 +285,14 @@ void UDPBaseImplementation::setUDPPortNumber(const uint32_t i){
FILE_LOG(logDEBUG) << __AT__ << " starting";
udpPortNum[0] = i;
FILE_LOG(logINFO) << "udpPortNum[0]:" << udpPortNum[0];
FILE_LOG(logINFO) << "UDP Port Number[0]:" << udpPortNum[0];
}
void UDPBaseImplementation::setUDPPortNumber2(const uint32_t i){
FILE_LOG(logDEBUG) << __AT__ << " starting";
udpPortNum[1] = i;
FILE_LOG(logINFO) << "udpPortNum[1]:" << udpPortNum[1];
FILE_LOG(logINFO) << "UDP Port Number[1]:" << udpPortNum[1];
}
void UDPBaseImplementation::setEthernetInterface(const char* c){
@ -325,7 +325,7 @@ int UDPBaseImplementation::setAcquisitionPeriod(const uint64_t i){
FILE_LOG(logDEBUG) << __AT__ << " starting";
acquisitionPeriod = i;
FILE_LOG(logINFO) << "Acquisition Period:" << acquisitionPeriod;
FILE_LOG(logINFO) << "Acquisition Period:" << (double)acquisitionPeriod/(1E9) << "s";
//overrridden child classes might return FAIL
return OK;
@ -389,7 +389,7 @@ void UDPBaseImplementation::resetAcquisitionCount(){
FILE_LOG(logDEBUG) << __AT__ << " starting";
totalPacketsCaught = 0;
FILE_LOG(logINFO) << "totalPacketsCaught:" << totalPacketsCaught << endl;
FILE_LOG(logINFO) << "totalPacketsCaught:" << totalPacketsCaught;
}
int UDPBaseImplementation::startReceiver(char *c){

View File

@ -23,7 +23,7 @@ using namespace std;
UDPInterface * UDPInterface::create(string receiver_type){
if (receiver_type == "standard"){
cout << "Starting " << receiver_type << endl;
FILE_LOG(logINFO) << "Starting " << receiver_type;
return new UDPStandardImplementation();
}
#ifdef REST

View File

@ -42,10 +42,11 @@ UDPStandardImplementation::UDPStandardImplementation(){
pthread_mutex_init(&progressMutex,NULL);
//to increase socket receiver buffer size and max length of input queue by changing kernel settings
if(system("echo $((100*1024*1024)) > /proc/sys/net/core/rmem_max"))
FILE_LOG(logDEBUG1) << "Warning: No root permission to change socket receiver buffer size in file /proc/sys/net/core/rmem_max" << endl;
if(myDetectorType == EIGER);
else if(system("echo $((100*1024*1024)) > /proc/sys/net/core/rmem_max"))
FILE_LOG(logDEBUG) << "Warning: No root permission to change socket receiver buffer size in file /proc/sys/net/core/rmem_max";
else if(system("echo 250000 > /proc/sys/net/core/netdev_max_backlog"))
FILE_LOG(logDEBUG1) << "Warning: No root permission to change max length of input queue in file /proc/sys/net/core/netdev_max_backlog" << endl;
FILE_LOG(logDEBUG) << "Warning: No root permission to change max length of input queue in file /proc/sys/net/core/netdev_max_backlog";
/** permanent setting by heiner
net.core.rmem_max = 104857600 # 100MiB
net.core.netdev_max_backlog = 250000
@ -54,7 +55,6 @@ UDPStandardImplementation::UDPStandardImplementation(){
sysctl -w net.core.rmem_max=16777216
sysctl -w net.core.netdev_max_backlog=250000
*/
cout << endl;
}
UDPStandardImplementation::~UDPStandardImplementation(){
@ -74,7 +74,7 @@ UDPStandardImplementation::~UDPStandardImplementation(){
void UDPStandardImplementation::deleteMembers(){
FILE_LOG(logDEBUG1) << __AT__ << " starting";
FILE_LOG(logDEBUG1) << "Info: Deleting member pointers" << endl;
FILE_LOG(logDEBUG) << "Info: Deleting member pointers";
shutDownUDPSockets();
closeFile();
//filter
@ -120,7 +120,7 @@ void UDPStandardImplementation::initializeBaseMembers(){
void UDPStandardImplementation::initializeMembers(){
FILE_LOG(logDEBUG1) << __AT__ << " starting";
FILE_LOG(logDEBUG1) << "Info: Initializing members" << endl;
FILE_LOG(logDEBUG) << "Info: Initializing members";
//***detector parameters***
frameSize = 0;
@ -257,7 +257,7 @@ int UDPStandardImplementation::setupFifoStructure(){
//eiger always listens to 1 packet at a time
if(myDetectorType == EIGER){
numberofJobsPerBuffer = 1;
FILE_LOG(logDEBUG1) << "Info: 1 packet per buffer" << endl;
FILE_LOG(logDEBUG) << "Info: 1 packet per buffer";
}
//else calculate best possible number of frames to listen to at a time (for fast readouts like gotthard)
@ -280,7 +280,7 @@ int UDPStandardImplementation::setupFifoStructure(){
numberofJobsPerBuffer = i;
}
cout << "Info: Number of Frames per buffer:" << numberofJobsPerBuffer << endl;
FILE_LOG(logINFO) << "Number of Frames per buffer:" << numberofJobsPerBuffer << endl;
}
//set fifo depth
@ -299,7 +299,7 @@ int UDPStandardImplementation::setupFifoStructure(){
else
fifoSize = fifoSize/numberofJobsPerBuffer;
}
FILE_LOG(logDEBUG1) << "Info: Fifo Depth:" << fifoSize << endl;
FILE_LOG(logDEBUG) << "Info: Fifo Depth:" << fifoSize;
@ -315,8 +315,8 @@ int UDPStandardImplementation::setupFifoStructure(){
if(fifoFree[i]){
while(!fifoFree[i]->isEmpty())
fifoFree[i]->pop(buffer[i]);
#ifdef FIFODEBUG
cprintf(GREEN,"Info: %d fifostructure popped from fifofree %p\n", i, (void*)(buffer[i]));
#ifdef DEBUG5
cprintf(BLUE,"Info: %d fifostructure popped from fifofree %p\n", i, (void*)(buffer[i]));
#endif
delete fifoFree[i];
}
@ -338,13 +338,13 @@ int UDPStandardImplementation::setupFifoStructure(){
buffer[i]=mem0[i];
while (buffer[i] < (mem0[i]+(bufferSize * numberofJobsPerBuffer + HEADER_SIZE_NUM_TOT_PACKETS) * (fifoSize-1))) {
fifoFree[i]->push(buffer[i]);
#ifdef FIFODEBUG
#ifdef DEBUG5
cprintf(BLUE,"Info: %d fifostructure free pushed into fifofree %p\n", i, (void*)(buffer[i]));
#endif
buffer[i] += (bufferSize * numberofJobsPerBuffer + HEADER_SIZE_NUM_TOT_PACKETS);
}
}
FILE_LOG(logDEBUG1) << "Info: Fifo structure(s) reconstructed" << endl;
FILE_LOG(logDEBUG) << "Info: Fifo structure(s) reconstructed";
return OK;
}
@ -366,7 +366,7 @@ void UDPStandardImplementation::configure(map<string, string> config_map){
b = 0;
}
bottomEnable = b!= 0;
cout << "Info: Bottom - " << stringEnable(bottomEnable) << endl;
FILE_LOG(logINFO) << "Bottom: " << stringEnable(bottomEnable);
}
}
@ -410,7 +410,7 @@ int UDPStandardImplementation::setDataCompressionEnable(const bool b){
if(b)
initializeFilter();
cout << "Info: Data Compression " << stringEnable(dataCompressionEnable) << endl;
FILE_LOG(logINFO) << "Data Compression: " << stringEnable(dataCompressionEnable);
return OK;
}
@ -450,7 +450,7 @@ void UDPStandardImplementation::setShortFrameEnable(const int i){
if(dataCompressionEnable)
initializeFilter();
cout << "Info: Short Frame Enable set to " << shortFrameEnable << endl;
FILE_LOG(logINFO) << "Short Frame Enable: " << shortFrameEnable;
}
@ -461,7 +461,7 @@ int UDPStandardImplementation::setFrameToGuiFrequency(const uint32_t i){
if(setupFifoStructure() == FAIL)
return FAIL;
cout << "Info: Frame to Gui Frequency set to " << FrameToGuiFrequency << endl;
FILE_LOG(logINFO) << "Frame to Gui Frequency: " << FrameToGuiFrequency;
return OK;
}
@ -474,7 +474,7 @@ int UDPStandardImplementation::setAcquisitionPeriod(const uint64_t i){
if(setupFifoStructure() == FAIL)
return FAIL;
cout << "Info: Acquisition Period set to " << acquisitionPeriod << endl;
FILE_LOG(logINFO) << "Acquisition Period: " << (double)acquisitionPeriod/(1E9) << "s";
return OK;
@ -485,7 +485,7 @@ int UDPStandardImplementation::setDynamicRange(const uint32_t i){
uint32_t oldDynamicRange = dynamicRange;
cout << "Info: Setting Dynamic Range to " << i << endl;
FILE_LOG(logDEBUG) << "Info: Setting Dynamic Range to " << i;
dynamicRange = i;
if(myDetectorType == EIGER){
@ -515,11 +515,11 @@ int UDPStandardImplementation::setDynamicRange(const uint32_t i){
//create threads
if(createListeningThreads() == FAIL){
cprintf(BG_RED,"Error: Could not create listening thread\n");
FILE_LOG(logERROR) << "Could not create listening thread";
return FAIL;
}
if(createWriterThreads() == FAIL){
cprintf(BG_RED,"Error: Could not create writer threads\n");
FILE_LOG(logERROR) << "Could not create writer threads";
return FAIL;
}
setThreadPriorities();
@ -527,7 +527,7 @@ int UDPStandardImplementation::setDynamicRange(const uint32_t i){
}
cout << "Info: Dynamic Range set to " << dynamicRange << endl;
FILE_LOG(logINFO) << "Dynamic Range: " << dynamicRange;
return OK;
}
@ -537,7 +537,7 @@ int UDPStandardImplementation::setDynamicRange(const uint32_t i){
int UDPStandardImplementation::setTenGigaEnable(const bool b){
FILE_LOG(logDEBUG1) << __AT__ << " called";
cout << "Info: Setting Ten Giga to " << stringEnable(b) << endl;
FILE_LOG(logDEBUG) << "Info: Setting Ten Giga to " << stringEnable(b);
bool oldTenGigaEnable = tengigaEnable;
tengigaEnable = b;
@ -557,13 +557,13 @@ int UDPStandardImplementation::setTenGigaEnable(const bool b){
bufferSize = onePacketSize;
maxPacketsPerFile = EIGER_MAX_FRAMES_PER_FILE * packetsPerFrame;
FILE_LOG(logDEBUG1) << dec <<
FILE_LOG(logDEBUG) << dec <<
"packetsPerFrame:" << packetsPerFrame <<
"\nonePacketSize:" << onePacketSize <<
"\noneDataSize:" << oneDataSize <<
"\nframesize:" << frameSize <<
"\nbufferSize:" << bufferSize <<
"\nmaxPacketsPerFile:" << maxPacketsPerFile << endl;
"\nmaxPacketsPerFile:" << maxPacketsPerFile;
@ -586,11 +586,11 @@ int UDPStandardImplementation::setTenGigaEnable(const bool b){
//create threads
if(createListeningThreads() == FAIL){
cprintf(BG_RED,"Error: Could not create listening thread\n");
FILE_LOG(logERROR) << "Could not create listening thread";
return FAIL;
}
if(createWriterThreads() == FAIL){
cprintf(BG_RED,"Error: Could not create writer threads\n");
FILE_LOG(logERROR) << "Could not create writer threads";
return FAIL;
}
setThreadPriorities();
@ -598,7 +598,7 @@ int UDPStandardImplementation::setTenGigaEnable(const bool b){
}
cout << "Info: Ten Giga " << stringEnable(tengigaEnable) << endl;
FILE_LOG(logINFO) << "Ten Giga: " << stringEnable(tengigaEnable);
return OK;
}
@ -619,7 +619,7 @@ int UDPStandardImplementation::setTenGigaEnable(const bool b){
int UDPStandardImplementation::setDetectorType(const detectorType d){
FILE_LOG(logDEBUG1) << __AT__ << " called";
cout << "Info: Setting receiver type ..." << endl;
FILE_LOG(logDEBUG) << "Setting receiver type";
deleteMembers();
initializeBaseMembers();
@ -633,10 +633,10 @@ int UDPStandardImplementation::setDetectorType(const detectorType d){
case EIGER:
case JUNGFRAUCTB:
case JUNGFRAU:
FILE_LOG(logINFO) << " ***** This is a " << getDetectorType(d) << " Receiver *****" << endl;
FILE_LOG(logINFO) << " ***** This is a " << getDetectorType(d) << " Receiver *****";
break;
default:
cprintf(BG_RED, "Error: This is an unknown receiver type %d\n", (int)d);
FILE_LOG(logERROR) << "This is an unknown receiver type " << (int)d;
return FAIL;
}
@ -710,7 +710,7 @@ int UDPStandardImplementation::setDetectorType(const detectorType d){
//footerOffset = Not applicable;
break;
default:
cprintf(BG_RED, "Error: This is an unknown receiver type %d\n", (int)d);
FILE_LOG(logERROR) << "This is an unknown receiver type " << (int)d;
return FAIL;
}
@ -730,11 +730,11 @@ int UDPStandardImplementation::setDetectorType(const detectorType d){
//create threads
if(createListeningThreads() == FAIL){
cprintf(BG_RED,"Error: Could not create listening thread\n");
FILE_LOG(logERROR) << "Could not create listening thread";
return FAIL;
}
if(createWriterThreads() == FAIL){
cprintf(BG_RED,"Error: Could not create writer threads\n");
FILE_LOG(logERROR) << "Could not create writer threads";
return FAIL;
}
setThreadPriorities();
@ -742,8 +742,7 @@ int UDPStandardImplementation::setDetectorType(const detectorType d){
//allocate for latest data (frame copy for gui)
latestData = new char[frameSize];
cout << " Detector type set to " << getDetectorType(d) << endl;
cout << "Ready..." << endl;
FILE_LOG(logDEBUG) << " Detector type set to " << getDetectorType(d);
return OK;
}
@ -757,15 +756,14 @@ void UDPStandardImplementation::resetAcquisitionCount(){
acqStarted = false;
startAcquisitionIndex = 0;
cout << "Info: Acquisition Count has been reset" << endl;
FILE_LOG(logINFO) << "Acquisition Count has been reset";
}
int UDPStandardImplementation::startReceiver(char *c){
FILE_LOG(logDEBUG1) << __AT__ << " called";
cout << endl;
cout << "Info: Starting Receiver" << endl;
FILE_LOG(logINFO) << "Starting Receiver";
//RESET
@ -804,32 +802,29 @@ int UDPStandardImplementation::startReceiver(char *c){
//Print Receiver Configuration
if(myDetectorType != EIGER){
cout << "Info: Data Compression has been " << stringEnable(dataCompressionEnable) << endl;
cout << "Info: Number of Jobs Per Buffer: " << numberofJobsPerBuffer << endl;
cout << "Info: Max Packets Per File:" << maxPacketsPerFile << endl;
FILE_LOG(logINFO) << "Data Compression has been " << stringEnable(dataCompressionEnable);
FILE_LOG(logINFO) << "Number of Jobs Per Buffer: " << numberofJobsPerBuffer;
FILE_LOG(logINFO) << "Max Packets Per File:" << maxPacketsPerFile;
}
if(FrameToGuiFrequency)
cout << "Info: requency of frames sent to gui: " << FrameToGuiFrequency << endl;
FILE_LOG(logINFO) << "Frequency of frames sent to gui: " << FrameToGuiFrequency;
else
cout << "Info: Frequency of frames sent to gui: Random" << endl;
FILE_LOG(logINFO) << "Frequency of frames sent to gui: Random";
//create UDP sockets
if(createUDPSockets() == FAIL){
strcpy(c,"Could not create UDP Socket(s).\n");
cout << endl;
cprintf(BG_RED, "Error: %s\n",c);
strcpy(c,"Could not create UDP Socket(s).");
FILE_LOG(logERROR) << c;
return FAIL;
}
if(setupWriter() == FAIL){
//stop udp socket
shutDownUDPSockets();
sprintf(c,"Could not create file %s.\n",completeFileName);
cout << endl;
cprintf(BG_RED, "Error: %s\n",c);
sprintf(c,"Could not create file %s.",completeFileName);
FILE_LOG(logERROR) << c;
return FAIL;
}
@ -854,8 +849,8 @@ int UDPStandardImplementation::startReceiver(char *c){
for(int i=0; i < numberofWriterThreads; i++) sem_post(&writerSemaphore[i]);
//usleep(5000000);
cout << "Info: Receiver Started." << endl;
cout << "Info: Status:" << runStatusType(status) << endl;
FILE_LOG(logINFO) << "Receiver Started";
FILE_LOG(logINFO) << "Status:" << runStatusType(status);
return OK;
}
@ -868,7 +863,7 @@ int UDPStandardImplementation::startReceiver(char *c){
void UDPStandardImplementation::stopReceiver(){
FILE_LOG(logDEBUG1) << __AT__ << " called";
cout << "Info: Stopping Receiver" << endl;
FILE_LOG(logINFO) << "Stopping Receiver";
//set status to transmitting
startReadout();
@ -887,8 +882,8 @@ void UDPStandardImplementation::stopReceiver(){
status = IDLE;
pthread_mutex_unlock(&(statusMutex));
cout << "Info: Receiver Stopped" << endl;
cout << "Info: Status:" << runStatusType(status) << endl;
FILE_LOG(logINFO) << "Receiver Stopped";
FILE_LOG(logINFO) << "Status:" << runStatusType(status);
cout << endl;
}
@ -899,7 +894,7 @@ void UDPStandardImplementation::stopReceiver(){
int UDPStandardImplementation::shutDownUDPSockets(){
FILE_LOG(logDEBUG1) << __AT__ << " called";
FILE_LOG(logDEBUG1) << "Info: Shutting down UDP Socket(s)" << endl;
FILE_LOG(logDEBUG) << "Info: Shutting down UDP Socket(s)";
for(int i=0;i<numberofListeningThreads;i++){
if(udpSocket[i]){
@ -921,7 +916,7 @@ int UDPStandardImplementation::shutDownUDPSockets(){
void UDPStandardImplementation::startReadout(){
FILE_LOG(logDEBUG1) << __AT__ << " called";
cout << "Info: Transmitting last data" << endl;
FILE_LOG(logDEBUG) << "Info: Transmitting last data";
if(status == RUNNING){
//wait for all packets
@ -936,7 +931,7 @@ void UDPStandardImplementation::startReadout(){
pthread_mutex_lock(&statusMutex);
status = TRANSMITTING;
pthread_mutex_unlock(&statusMutex);
cout << "Info: Status: Transmitting" << endl;
FILE_LOG(logINFO) << "Status: Transmitting";
}
//shut down udp sockets and make listeners push dummy (end) packets for writers
@ -1003,7 +998,7 @@ void UDPStandardImplementation::closeFile(int i){
if(!dataCompressionEnable){
if(sfilefd){
#ifdef DEBUG4
cprintf(YELLOW, "Going to close file:%d\n",fileno(sfilefd));
FILE_LOG(logDEBUG4) << "Going to close file: " << fileno(sfilefd));
#endif
fclose(sfilefd);
sfilefd = NULL;
@ -1015,7 +1010,7 @@ void UDPStandardImplementation::closeFile(int i){
#if (defined(MYROOT1) && defined(ALLFILE_DEBUG)) || !defined(MYROOT1)
if(sfilefd){
#ifdef DEBUG4
cout << "sfield:" << (int)sfilefd << endl;
FILE_LOG(logDEBUG4) << "sfield: " << (int)sfilefd;
#endif
fclose(sfilefd);
sfilefd = NULL;
@ -1030,12 +1025,12 @@ void UDPStandardImplementation::closeFile(int i){
if(myFile[i]->Write())
//->Write(tall->GetName(),TObject::kOverwrite);
cout << "Info: Thread " << i <<": wrote frames to file" << endl;
FILE_LOG(logINFO) << "Thread " << i <<": wrote frames to file";
else
cout << "Info: Thread " << i << ": could not write frames to file" << endl;
FILE_LOG(logINFO) << "Thread " << i << ": could not write frames to file";
}else
cout << "Info: Thread " << i << ": could not write frames to file: No file or No Tree" << endl;
FILE_LOG(logINFO) << "Thread " << i << ": could not write frames to file: No file or No Tree";
//close file
if(myTree[i] && myFile[i])
myFile[i] = myTree[i]->GetCurrentFile();
@ -1068,23 +1063,22 @@ int UDPStandardImplementation::createListeningThreads(bool destroy){
//destroy
if(destroy){
FILE_LOG(logDEBUG) << "Info: Destroying Listening Thread(s)" << endl;
FILE_LOG(logDEBUG) << "Info: Destroying Listening Thread(s)";
killAllListeningThreads = true;
for(int i = 0; i < numberofListeningThreads; ++i){
sem_post(&listenSemaphore[i]);
pthread_join(listeningThreads[i],NULL);
cout <<"."<<flush;
FILE_LOG(logDEBUG) << "." << flush;
}
killAllListeningThreads = false;
threadStarted = false;
cout << endl;
FILE_LOG(logDEBUG) << "Info: Listening thread(s) destroyed" << endl;
FILE_LOG(logDEBUG) << "Info: Listening thread(s) destroyed";
}
//create
else{
FILE_LOG(logDEBUG) << "Info: Creating Listening Thread(s)" << endl;
FILE_LOG(logDEBUG) << "Info: Creating Listening Thread(s)";
//reset current index
currentThreadIndex = -1;
@ -1094,18 +1088,13 @@ int UDPStandardImplementation::createListeningThreads(bool destroy){
threadStarted = false;
currentThreadIndex = i;
if(pthread_create(&listeningThreads[i], NULL,startListeningThread, (void*) this)){
cout << "Warning: Could not create listening thread with index " << i << endl;
FILE_LOG(logERROR) << "Could not create listening thread with index " << i;
return FAIL;
}
while(!threadStarted);
cout << ".";
cout << flush;
FILE_LOG(logDEBUG) << "." << flush;
}
cout << endl;
#ifdef VERBOSE
FILE_LOG(logDEBUG) << "Info: Listening thread(s) created successfully." << endl;
#endif
FILE_LOG(logDEBUG) << "Info: Listening thread(s) created successfully.";
}
return OK;
@ -1125,23 +1114,22 @@ int UDPStandardImplementation::createWriterThreads(bool destroy){
//destroy threads
if(destroy){
cout << "Info: Destroying Writer Thread(s)" << endl;
FILE_LOG(logDEBUG) << "Info: Destroying Writer Thread(s)";
killAllWritingThreads = true;
for(int i = 0; i < numberofWriterThreads; ++i){
sem_post(&writerSemaphore[i]);
pthread_join(writingThreads[i],NULL);
cout <<"."<<flush;
FILE_LOG(logDEBUG) <<"."<<flush;
}
killAllWritingThreads = false;
threadStarted = false;
cout << endl;
cout << "Info: Writer thread(s) destroyed" << endl;
FILE_LOG(logDEBUG) << "Info: Writer thread(s) destroyed";
}
//create threads
else{
cout << "Info: Creating Writer Thread(s)" << endl;
FILE_LOG(logDEBUG) << "Info: Creating Writer Thread(s)";
//reset current index
currentThreadIndex = -1;
@ -1151,16 +1139,14 @@ int UDPStandardImplementation::createWriterThreads(bool destroy){
threadStarted = false;
currentThreadIndex = i;
if(pthread_create(&writingThreads[i], NULL,startWritingThread, (void*) this)){
cout << "Warning: Could not create writer thread with index " << i << endl;
FILE_LOG(logERROR) << "Could not create writer thread with index " << i;
return FAIL;
}
while(!threadStarted);
cout << ".";
cout << flush;
FILE_LOG(logDEBUG) << "." << flush;
}
cout << endl;
#ifdef VERBOSE
cout << "Info: Writer thread(s) created successfully." << endl;
FILE_LOG(logINFO) << "\nWriter thread(s) created successfully.";
#endif
}
@ -1198,7 +1184,7 @@ void UDPStandardImplementation::setThreadPriorities(){
rights = false;
if(!rights)
cout << "Warning: No root permission to prioritize threads." << endl;
FILE_LOG(logWARNING) << "No root permission to prioritize threads.";
}
@ -1226,14 +1212,14 @@ int UDPStandardImplementation::createUDPSockets(){
//if no eth, listen to all
if(!strlen(eth)){
cout << "Warning: eth is empty. Listening to all"<<endl;
FILE_LOG(logWARNING) << "eth is empty. Listening to all";
for(int i=0;i<numberofListeningThreads;i++)
udpSocket[i] = new genericSocket(port[i],genericSocket::UDP,bufferSize);
}
//normal socket
else{
cout << "Info: eth:" << eth << endl;
FILE_LOG(logINFO) << "eth:" << eth << endl;
for(int i=0;i<numberofListeningThreads;i++)
udpSocket[i] = new genericSocket(port[i],genericSocket::UDP,bufferSize,eth);
@ -1243,18 +1229,16 @@ int UDPStandardImplementation::createUDPSockets(){
for(int i=0;i<numberofListeningThreads;i++){
int iret = udpSocket[i]->getErrorStatus();
if(!iret){
cout << "Info: UDP port opened at port " << port[i] << endl;
FILE_LOG(logINFO) << "UDP port opened at port " << port[i];
}else{
#ifdef VERBOSE
cprintf(BG_RED,"Error: Could not create UDP socket on port %d error: %d\n", port[i], iret);
#endif
FILE_LOG(logERROR) << "Could not create UDP socket on port " << port[i] << " error: " << iret;
shutDownUDPSockets();
return FAIL;
}
}
cout << "Info: UDP socket(s) created successfully." << endl;
cout << "Info: Listener Ready ..." << endl;
FILE_LOG(logDEBUG) << "UDP socket(s) created successfully.";
FILE_LOG(logINFO) << "Listener Ready ...";
return OK;
}
@ -1270,11 +1254,11 @@ int UDPStandardImplementation::setupWriter(){
cbAction=startAcquisitionCallBack(filePath,fileName,(int)fileIndex,bufferSize,pStartAcquisition);
if(cbAction < DO_EVERYTHING){
cout << "Info: Call back activated. Data saving must be taken care of by user in call back." << endl;
FILE_LOG(logINFO) << "Call back activated. Data saving must be taken care of by user in call back.";
if (rawDataReadyCallBack)
cout << "Info: Data Write has been defined externally" << endl;
FILE_LOG(logINFO) << "Data Write has been defined externally";
}else if(!fileWriteEnable)
cout << "Info: Data will not be saved" << endl;
FILE_LOG(logINFO) << "Data will not be saved";
@ -1285,7 +1269,7 @@ int UDPStandardImplementation::setupWriter(){
pthread_mutex_unlock(&statusMutex);
for(int i=0; i<numberofWriterThreads; i++){
FILE_LOG(logDEBUG4) << i << " Going to post 1st semaphore" << endl;
FILE_LOG(logDEBUG4) << i << " Going to post 1st semaphore";
sem_post(&writerSemaphore[i]);
}
//wait till its mask becomes zero(all created)
@ -1302,8 +1286,8 @@ int UDPStandardImplementation::setupWriter(){
#endif
}
cout << "Info: Successfully created file(s)" << endl;
cout << "Info: Writer Ready ..." << endl;
FILE_LOG(logDEBUG) << "Successfully created file(s)";
FILE_LOG(logINFO) << "Writer Ready ...";
return fileCreateSuccess;
}
@ -1326,7 +1310,7 @@ int UDPStandardImplementation::createNewFile(){
sprintf(completeFileName, "%s/%s_f%012lld_%lld.raw", filePath,fileName,(long long int)(packetsCaught/packetsPerFrame),(long long int)fileIndex);
#ifdef DEBUG4
cout << "Info: " << completefileName << endl;
FILE_LOG(logINFO) << completefileName;
#endif
//filewrite enable & we allowed to create/close files
@ -1341,11 +1325,11 @@ int UDPStandardImplementation::createNewFile(){
//create file
if(!overwriteEnable){
if (NULL == (sfilefd = fopen((const char *) (completeFileName), "wx"))){
cprintf(BG_RED,"Error: Could not create/overwrite file %s\n",completeFileName);
FILE_LOG(logERROR) << "Could not create/overwrite file" << completeFileName;
return FAIL;
}
}else if (NULL == (sfilefd = fopen((const char *) (completeFileName), "w"))){
cprintf(BG_RED,"Error: Could not create file %s\n",completeFileName);
FILE_LOG(logERROR) << "Could not create file" << completeFileName;
return FAIL;
}
//setting file buffer size to 16mb
@ -1354,9 +1338,9 @@ int UDPStandardImplementation::createNewFile(){
//Print packet loss and filenames
if(!packetsCaught){
previousFrameNumber = -1;
cout << "Info: " << completeFileName << endl;
FILE_LOG(logINFO) << "File: " << completeFileName;
}else{
cout << "Info:" << completeFileName
FILE_LOG(logINFO) << completeFileName
<< "\tPacket Loss: " << setw(4)<<fixed << setprecision(4) << dec <<
(int)((( (currentFrameNumber-previousFrameNumber) - ((packetsInFile-numTotMissingPacketsInFile)/packetsPerFrame))/
(double)(currentFrameNumber-previousFrameNumber))*100.000)
@ -1364,7 +1348,7 @@ int UDPStandardImplementation::createNewFile(){
//<< "\t\t PreviousFrameNumber: " << previousFrameNumber
<< "\tIndex " << dec << index
<< "\tLost " << dec << ( ((int)(currentFrameNumber-previousFrameNumber)) -
((packetsInFile-numTotMissingPacketsInFile)/packetsPerFrame)) << endl;
((packetsInFile-numTotMissingPacketsInFile)/packetsPerFrame));
}
@ -1399,11 +1383,11 @@ int UDPStandardImplementation::createCompressionFile(int ithread, int iframe){
//resets the pedestalSubtraction array and the commonModeSubtraction
singlePhotonDetectorObject[ithread]->newDataSet();
if(myFile[ithread]==NULL){
cprintf(BG_RED,"Error: File Null\n");
FILE_LOG(logERROR) << "File Null";
return FAIL;
}
if(!myFile[ithread]->IsOpen()){
cprintf(BG_RED,"Error: File Not Open\n")
FILE_LOG(logERROR) << "File Not Open";
return FAIL;
}
return OK;
@ -1464,13 +1448,13 @@ void UDPStandardImplementation::startListening(){
//pop from fifo
fifoFree[ithread]->pop(buffer[ithread]);
#ifdef FIFODEBUG
cprintf(BLUE,"%d :Listener popped from fifofree %p\n", ithread, (void*)(buffer[ithread]));
#ifdef DEBUG5
cprintf(BLUE,"Listening_Thread %d :Listener popped from fifofree %p\n", ithread, (void*)(buffer[ithread]));
#endif
//udpsocket doesnt exist
if(udpSocket[ithread] == NULL){
cprintf(RED, "Error: Thread %d :UDP Socket not created\n",ithread);
FILE_LOG(logERROR) << "Listening_Thread " << ithread << ": UDP Socket not created";
stopListening(ithread,0);
continue;
}
@ -1501,7 +1485,7 @@ void UDPStandardImplementation::startListening(){
//push buffer to FIFO
while(!fifo[ithread]->push(buffer[ithread]));
#ifdef FIFODEBUG
#ifdef DEBUG5
cprintf(BLUE,"Listening_Thread %d: Listener pushed into fifo %p\n",ithread, (void*)(buffer[ithread]));
#endif
@ -1512,7 +1496,7 @@ void UDPStandardImplementation::startListening(){
//check to exit thread (for change of parameters) - only EXIT possibility
if(killAllListeningThreads){
cprintf(GREEN,"Listening_Thread %d:Goodbye!\n",ithread);
cprintf(BLUE,"Listening_Thread %d:Goodbye!\n",ithread);
//free resources at exit
if(tempBuffer) delete[] tempBuffer;
pthread_exit(NULL);
@ -1544,7 +1528,7 @@ int UDPStandardImplementation::prepareAndListenBuffer(int ithread, int lSize, in
}
#ifdef DEBUG
cprintf(BLUE, "Listening_Thread %d : Received bytes: %d. Expected bytes: %d\n", ithread, receivedSize, expected-cSize);
cprintf(BLUE, "Listening_Thread %d : Received bytes: %d. Expected bytes: %d\n", ithread, receivedSize, bufferSize * numberofJobsPerBuffer-cSize);
#endif
return receivedSize;
}
@ -1577,11 +1561,11 @@ void UDPStandardImplementation::startFrameIndices(int ithread){
if(!acqStarted){
startAcquisitionIndex = startFrameIndex;
acqStarted = true;
cprintf(BLUE,"Info: Thread %d: startAcquisitionIndex:%lld\n",ithread,(long long int)startAcquisitionIndex);
cprintf(BLUE,"Listening_Thread %d: startAcquisitionIndex:%lld\n",ithread,(long long int)startAcquisitionIndex);
}
//set start of scan/real time measurement
cprintf(BLUE,"Info: Thread %d: startFrameIndex: %lld\n", ithread,(long long int)startFrameIndex);
cprintf(BLUE,"Listening_Thread %d: startFrameIndex: %lld\n", ithread,(long long int)startFrameIndex);
measurementStarted = true;
}
@ -1594,8 +1578,7 @@ void UDPStandardImplementation::startFrameIndices(int ithread){
void UDPStandardImplementation::stopListening(int ithread, int numbytes){
FILE_LOG(logDEBUG1) << __AT__ << " called";
cout << "Info: Thread " << ithread << ": Stop Listening.\nStatus:" << runStatusType(status) << endl;
cprintf(BLUE,"Listening_Thread %d: Stop Listening.\nStatus:%s\n", ithread, runStatusType(status).c_str());
//less than 1 packet size (especially for eiger), ignore the buffer (so that 2 dummy buffers are not sent with pc=0)
if(numbytes < onePacketSize)
@ -1604,9 +1587,9 @@ void UDPStandardImplementation::stopListening(int ithread, int numbytes){
//free empty buffer
if(numbytes <= 0){
cprintf(BLUE,"Info: Thread %d :End of Acquisition for Listening Thread\n", ithread);
cprintf(BLUE,"Listening_Thread %d :End of Acquisition\n", ithread);
while(!fifoFree[ithread]->push(buffer[ithread]));
#ifdef FIFODEBUG
#ifdef DEBUG5
cprintf(BLUE,"Listening_Thread %d :Listener push empty buffer into fifofree %p\n", ithread, (void*)(buffer[ithread]));
#endif
}
@ -1621,7 +1604,7 @@ void UDPStandardImplementation::stopListening(int ithread, int numbytes){
cprintf(BLUE,"Listening_Thread %d: Last Buffer packet count:%d\n",ithread, numbytes/onePacketSize);
#endif
while(!fifo[ithread]->push(buffer[ithread]));
#ifdef FIFODEBUG
#ifdef DEBUG5
cprintf(BLUE,"Listening_Thread %d: Listener Last Buffer pushed into fifo %p\n", ithread,(void*)(buffer[ithread]));
#endif
}
@ -1632,7 +1615,7 @@ void UDPStandardImplementation::stopListening(int ithread, int numbytes){
//creating dummy-end buffer with pc=0xFFFF
(*((uint32_t*)(buffer[ithread]))) = dummyPacketValue;
while(!fifo[ithread]->push(buffer[ithread]));
#ifdef FIFODEBUG
#ifdef DEBUG5
cprintf(BLUE,"Listening_Thread %d: Listener pushed dummy-end buffer into fifo %p\n", ithread,(void*)(buffer[ithread]));
#endif
}
@ -1797,7 +1780,7 @@ void UDPStandardImplementation::processWritingBuffer(int ithread){
while((1 << ithread) & writerThreadsMask){
//pop
fifo[0]->pop(wbuf[0]);
#ifdef FIFODEBUG
#ifdef DEBUG5
cprintf(GREEN,"Writing_Thread %d: Popped %p from FIFO %d\n", ithread, (void*)(wbuf[0]),0);
#endif
uint32_t numPackets = (uint32_t)(*((uint32_t*)wbuf[0]));
@ -1952,7 +1935,7 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){
//update frame number and packet number
if(numPackets[i] != dummyPacketValue){
if(!((uint32_t)(*( (uint64_t*) packetBuffer_footer)))){
cprintf(BG_RED,"Fifo %d: Error: Frame Number is zero from firmware. popready[%d]:%d\n",i,i,popReady[i]);
FILE_LOG(logERROR) << "Fifo "<< i << ": Frame Number is zero from firmware. popready[" << i << "]:" << popReady[i];
popReady[i]=true;
continue;
}
@ -2090,13 +2073,13 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){
//freeing
for(int j=0;j<toFreePointersOffset[0];++j){
while(!fifoFree[0]->push(toFreePointers[j]));
#ifdef FIFODEBUG
#ifdef DEBUG5
cprintf(GREEN,"Fifo 0: Writing_Thread freed: pushed into fifofree %p\n",ithread, (void*)(toFreePointers[j]));
#endif
}
for(int j=(packetsPerFrame/numberofListeningThreads);j<toFreePointersOffset[1];++j){
while(!fifoFree[1]->push(toFreePointers[j]));
#ifdef FIFODEBUG
#ifdef DEBUG5
cprintf(GREEN,"Fifo 1: Writing_Thread freed: pushed into fifofree %p\n",ithread, (void*)(toFreePointers[j]));
#endif
}
@ -2210,7 +2193,7 @@ bool UDPStandardImplementation::popAndCheckEndofAcquisition(int ithread, char* w
//pop if ready
if(ready[i]){
fifo[i]->pop(wbuffer[i]);
#ifdef FIFODEBUG
#ifdef DEBUG5
cprintf(GREEN,"Writing_Thread %d: Popped %p from FIFO %d\n", ithread, (void*)(wbuffer[i]),i);
#endif
nP[i] = (uint32_t)(*((uint32_t*)wbuffer[i]));
@ -2259,7 +2242,7 @@ void UDPStandardImplementation::stopWriting(int ithread, char* wbuffer[]){
//free fifo
for(int i=0; i<numberofListeningThreads; ++i){
while(!fifoFree[i]->push(wbuffer[i]));
#ifdef FIFODEBUG
#ifdef DEBUG5
cprintf(GREEN,"Writing_Thread %d: Freeing dummy-end buffer. Pushed into fifofree %p for listener %d\n", ithread,(void*)(wbuffer[i]),i);
#endif
}
@ -2296,9 +2279,9 @@ void UDPStandardImplementation::stopWriting(int ithread, char* wbuffer[]){
//statistics
cprintf(GREEN, "Status: Run Finished\n");
if(!totalPacketsCaught){
if((long long int)(totalPacketsCaught/packetsPerFrame) == 0){
cprintf(RED, "Total Missing Packets padded: %d\n",numTotMissingPackets);
cprintf(RED, "Total Packets Caught: 0\n");
cprintf(RED, "Total Packets Caught: %lld\n",(long long int)totalPacketsCaught);
cprintf(RED, "Total Frames Caught: 0\n");
}else{
cprintf(GREEN, "Total Missing Packets padded: %d\n",numTotMissingPackets);
@ -2365,7 +2348,7 @@ void UDPStandardImplementation::handleWithoutDataCompression(int ithread, char*
//free fifo addresses (eiger frees for each packet later)
if(myDetectorType != EIGER){
while(!fifoFree[0]->push(wbuffer[0]));
#ifdef FIFODEBUG
#ifdef DEBUG5
cprintf(GREEN,"Writing_Thread %d: Freed buffer, pushed into fifofree %p for listener 0\n",ithread, (void*)(wbuffer[0]));
#endif
}
@ -2701,7 +2684,7 @@ void UDPStandardImplementation::handleDataCompression(int ithread, char* wbuffer
while(!fifoFree[0]->push(wbuffer[0]));
#ifdef FIFODEBUG
#ifdef DEBUG5
cprintf(GREEN,"Writing_Thread %d: Compression free pushed into fifofree %p for listerner 0\n", ithread, (void*)(wbuffer[0]));
#endif
}

View File

@ -125,14 +125,14 @@ int slsReceiverTCPIPInterface::setPortNumber(int pn){
int slsReceiverTCPIPInterface::start(){
FILE_LOG(logDEBUG1) << "Creating TCP Server Thread" << endl;
FILE_LOG(logDEBUG) << "Creating TCP Server Thread" << endl;
killTCPServerThread = 0;
if(pthread_create(&TCPServer_thread, NULL,startTCPServerThread, (void*) this)){
cout << "Could not create TCP Server thread" << endl;
return FAIL;
}
//#ifdef VERBOSE
FILE_LOG(logDEBUG1) << "TCP Server thread created successfully." << endl;
FILE_LOG(logDEBUG) << "TCP Server thread created successfully." << endl;
//#endif
return OK;
}
@ -395,25 +395,27 @@ int slsReceiverTCPIPInterface::set_detector_type(){
if(ret != FAIL){
#ifndef REST
receiverBase = UDPInterface::create("standard");
receiverBase->setBottomEnable(bottom);
#endif
myDetectorType = dr;
ret=receiverBase->setDetectorType(myDetectorType);
retval = myDetectorType;
#ifndef REST
receiverBase->setBottomEnable(bottom);
#endif
}
}
}
//#ifdef VERBOSE
if(ret!=FAIL)
cout << "detector type " << dr << endl;
FILE_LOG(logDEBUG) << "detector type " << dr;
else
cprintf(RED, "%s\n", mess);
//#endif
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
@ -474,7 +476,7 @@ int slsReceiverTCPIPInterface::set_file_name() {
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
@ -546,7 +548,7 @@ int slsReceiverTCPIPInterface::set_file_dir() {
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
@ -612,7 +614,7 @@ int slsReceiverTCPIPInterface::set_file_index() {
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
@ -685,7 +687,7 @@ int slsReceiverTCPIPInterface::set_frame_index() {
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
@ -748,12 +750,12 @@ int slsReceiverTCPIPInterface::setup_udp(){
receiverBase->setUDPPortNumber2(udpport2);
//setup udpip
//get ethernet interface or IP to listen to
cout << "Ethernet interface is " << args[0] << endl;
FILE_LOG(logINFO) << "Receiver UDP IP: " << args[0];
temp = genericSocket::ipToName(args[0]);
cout << temp << endl;
if(temp=="none"){
ret = FAIL;
strcpy(mess, "failed to get ethernet interface or IP to listen to\n");
strcpy(mess, "Failed to get ethernet interface or IP\n");
FILE_LOG(logERROR) << mess;
}
else{
strcpy(eth,temp.c_str());
@ -761,9 +763,7 @@ int slsReceiverTCPIPInterface::setup_udp(){
strcpy(eth,"");
ret = FAIL;
}
FILE_LOG(logDEBUG) << __FILE__ << "::" << __func__ << " " << eth;
receiverBase->setEthernetInterface(eth);
cout << eth << endl;
//get mac address from ethernet interface
if (ret != FAIL)
@ -773,11 +773,10 @@ int slsReceiverTCPIPInterface::setup_udp(){
if ((temp=="00:00:00:00:00:00") || (ret == FAIL)){
ret = FAIL;
strcpy(mess,"failed to get mac adddress to listen to\n");
cprintf(RED,"%s\n",mess);
}
else{
strcpy(retval,temp.c_str());
cout<<"mac:"<<retval<<endl;
FILE_LOG(logINFO) << "Reciever MAC Address: " << retval;
}
}
}
@ -785,14 +784,14 @@ int slsReceiverTCPIPInterface::setup_udp(){
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
// send answer
socket->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
cprintf(RED, "%s\n", mess);
FILE_LOG(logERROR) << mess;
socket->SendDataOnly(mess,sizeof(mess));
}
socket->SendDataOnly(retval,MAX_STR_LENGTH);
@ -840,7 +839,7 @@ int slsReceiverTCPIPInterface::start_receiver(){
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
@ -886,7 +885,7 @@ int slsReceiverTCPIPInterface::stop_receiver(){
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
@ -916,7 +915,7 @@ int slsReceiverTCPIPInterface::get_status(){
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
@ -946,7 +945,7 @@ int slsReceiverTCPIPInterface::get_frames_caught(){
}else retval=receiverBase->getTotalFramesCaught();
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
@ -978,7 +977,7 @@ int slsReceiverTCPIPInterface::get_frame_index(){
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
@ -1019,7 +1018,7 @@ int slsReceiverTCPIPInterface::reset_frames_caught(){
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
@ -1087,7 +1086,7 @@ int slsReceiverTCPIPInterface::set_short_frame() {
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
@ -1267,7 +1266,7 @@ int slsReceiverTCPIPInterface::moench_read_frame(){
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
@ -1448,7 +1447,7 @@ int slsReceiverTCPIPInterface::gotthard_read_frame(){
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
@ -1602,7 +1601,7 @@ int slsReceiverTCPIPInterface::propix_read_frame(){
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
@ -1864,7 +1863,7 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
@ -1939,7 +1938,7 @@ int slsReceiverTCPIPInterface::set_read_frequency(){
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
@ -1995,7 +1994,7 @@ int slsReceiverTCPIPInterface::enable_file_write(){
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
@ -2023,7 +2022,7 @@ int slsReceiverTCPIPInterface::get_id(){
#endif
if(socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
@ -2066,7 +2065,7 @@ int slsReceiverTCPIPInterface::start_readout(){
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
@ -2140,7 +2139,7 @@ int slsReceiverTCPIPInterface::set_timer() {
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
@ -2211,7 +2210,7 @@ int slsReceiverTCPIPInterface::enable_compression() {
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
@ -2272,7 +2271,7 @@ int slsReceiverTCPIPInterface::set_detector_hostname() {
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
@ -2364,7 +2363,7 @@ int slsReceiverTCPIPInterface::set_dynamic_range() {
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
@ -2427,7 +2426,7 @@ int slsReceiverTCPIPInterface::enable_overwrite() {
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
@ -2492,7 +2491,7 @@ int slsReceiverTCPIPInterface::enable_tengiga() {
#endif
if(ret==OK && socket->differentClients){
cout << "Force update" << endl;
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}