Merge branch 'developer' into gotthard2testing

This commit is contained in:
maliakal_d 2020-01-29 11:37:59 +01:00
commit 5761642da0
7 changed files with 35 additions and 30 deletions

View File

@ -361,7 +361,7 @@ void qTabAdvanced::SetDetectorUDPIP() {
std::string s = dispDetectorUDPIP->text().toAscii().constData(); std::string s = dispDetectorUDPIP->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Detector UDP IP:" << s; FILE_LOG(logINFO) << "Setting Detector UDP IP:" << s;
try { try {
det->setSourceUDPIP(s, {comboDetector->currentIndex()}); det->setSourceUDPIP(sls::IpAddr{s}, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Detector UDP IP.", } CATCH_HANDLE ("Could not set Detector UDP IP.",
"qTabAdvanced::SetDetectorUDPIP", this, "qTabAdvanced::SetDetectorUDPIP", this,
&qTabAdvanced::GetDetectorUDPIP) &qTabAdvanced::GetDetectorUDPIP)
@ -371,7 +371,7 @@ void qTabAdvanced::SetDetectorUDPMAC() {
std::string s = dispDetectorUDPMAC->text().toAscii().constData(); std::string s = dispDetectorUDPMAC->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Detector UDP MAC:" << s; FILE_LOG(logINFO) << "Setting Detector UDP MAC:" << s;
try { try {
det->setSourceUDPMAC(s, {comboDetector->currentIndex()}); det->setSourceUDPMAC(sls::MacAddr{s}, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Detector UDP MAC.", } CATCH_HANDLE ("Could not set Detector UDP MAC.",
"qTabAdvanced::SetDetectorUDPMAC", this, "qTabAdvanced::SetDetectorUDPMAC", this,
&qTabAdvanced::GetDetectorUDPMAC) &qTabAdvanced::GetDetectorUDPMAC)
@ -390,7 +390,7 @@ void qTabAdvanced::SetCltZMQIP() {
std::string s = dispZMQIP->text().toAscii().constData(); std::string s = dispZMQIP->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Client ZMQ IP:" << s; FILE_LOG(logINFO) << "Setting Client ZMQ IP:" << s;
try { try {
det->setClientZmqIp(s, {comboDetector->currentIndex()}); det->setClientZmqIp(sls::IpAddr{s}, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Client ZMQ IP.", } CATCH_HANDLE ("Could not set Client ZMQ IP.",
"qTabAdvanced::SetCltZMQIP", this, "qTabAdvanced::SetCltZMQIP", this,
&qTabAdvanced::GetCltZMQIP) &qTabAdvanced::GetCltZMQIP)
@ -431,7 +431,7 @@ void qTabAdvanced::SetRxrUDPIP() {
std::string s = dispRxrUDPIP->text().toAscii().constData(); std::string s = dispRxrUDPIP->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Receiver UDP IP:" << s; FILE_LOG(logINFO) << "Setting Receiver UDP IP:" << s;
try { try {
det->setDestinationUDPIP(s, {comboDetector->currentIndex()}); det->setDestinationUDPIP(sls::IpAddr{s}, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver UDP IP.", } CATCH_HANDLE ("Could not set Receiver UDP IP.",
"qTabAdvanced::SetRxrUDPIP", this, "qTabAdvanced::SetRxrUDPIP", this,
&qTabAdvanced::GetRxrUDPIP) &qTabAdvanced::GetRxrUDPIP)
@ -441,7 +441,7 @@ void qTabAdvanced::SetRxrUDPMAC() {
std::string s = dispRxrUDPMAC->text().toAscii().constData(); std::string s = dispRxrUDPMAC->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Receiver UDP MAC:" << s; FILE_LOG(logINFO) << "Setting Receiver UDP MAC:" << s;
try { try {
det->setDestinationUDPMAC(s, {comboDetector->currentIndex()}); det->setDestinationUDPMAC(sls::MacAddr{s}, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver UDP MAC.", } CATCH_HANDLE ("Could not set Receiver UDP MAC.",
"qTabAdvanced::SetRxrUDPMAC", this, "qTabAdvanced::SetRxrUDPMAC", this,
&qTabAdvanced::GetRxrUDPMAC) &qTabAdvanced::GetRxrUDPMAC)
@ -460,7 +460,7 @@ void qTabAdvanced::SetRxrZMQIP() {
std::string s = dispRxrZMQIP->text().toAscii().constData(); std::string s = dispRxrZMQIP->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Receiver ZMQ IP:" << s; FILE_LOG(logINFO) << "Setting Receiver ZMQ IP:" << s;
try { try {
det->setRxZmqIP(s, {comboDetector->currentIndex()}); det->setRxZmqIP(sls::IpAddr{s}, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver ZMQ IP.", } CATCH_HANDLE ("Could not set Receiver ZMQ IP.",
"qTabAdvanced::SetRxrZMQIP", this, "qTabAdvanced::SetRxrZMQIP", this,
&qTabAdvanced::GetRxrZMQIP) &qTabAdvanced::GetRxrZMQIP)

View File

@ -196,10 +196,9 @@ class BinaryFileStatic {
* @param fd file pointer * @param fd file pointer
* @param owenable overwrite enable * @param owenable overwrite enable
* @param fname complete file name * @param fname complete file name
* @param filebuffersize file buffer size
* @returns 0 for success and 1 for fail * @returns 0 for success and 1 for fail
*/ */
static void CreateDataFile(FILE*& fd, bool owenable, std::string fname, size_t filebuffersize) static void CreateDataFile(FILE*& fd, bool owenable, std::string fname)
{ {
if(!owenable){ if(!owenable){
if (NULL == (fd = fopen((const char *) fname.c_str(), "wx"))){ if (NULL == (fd = fopen((const char *) fname.c_str(), "wx"))){
@ -210,8 +209,8 @@ class BinaryFileStatic {
fd = 0; fd = 0;
throw sls::RuntimeError("Could not create file " + fname); throw sls::RuntimeError("Could not create file " + fname);
} }
//setting file buffer size to 16mb //setting to no file buffering
setvbuf(fd,NULL,_IOFBF,filebuffersize); setvbuf(fd, NULL, _IONBF, 0);
} }
}; };

View File

@ -49,7 +49,7 @@ void BinaryFile::CreateFile() {
currentFileName = BinaryFileStatic::CreateFileName(*filePath, *fileNamePrefix, *fileIndex, currentFileName = BinaryFileStatic::CreateFileName(*filePath, *fileNamePrefix, *fileIndex,
subFileIndex, *detIndex, *numUnitsPerDetector, index); subFileIndex, *detIndex, *numUnitsPerDetector, index);
BinaryFileStatic::CreateDataFile(filefd, *overWriteEnable, currentFileName, FILE_BUFFER_SIZE); BinaryFileStatic::CreateDataFile(filefd, *overWriteEnable, currentFileName);
if(!(*silentMode)) { if(!(*silentMode)) {
FILE_LOG(logINFO) << "[" << *udpPortNumber << "]: Binary File created: " << currentFileName; FILE_LOG(logINFO) << "[" << *udpPortNumber << "]: Binary File created: " << currentFileName;

View File

@ -45,13 +45,17 @@ void Fifo::CreateFifos(uint32_t fifoItemSize) {
fifoFree = new CircularFifo<char>(fifoDepth); fifoFree = new CircularFifo<char>(fifoDepth);
fifoStream = new CircularFifo<char>(fifoDepth); fifoStream = new CircularFifo<char>(fifoDepth);
//allocate memory //allocate memory
size_t mem_len = fifoItemSize * fifoDepth * sizeof(char); size_t mem_len = (size_t)fifoItemSize * (size_t)fifoDepth * sizeof(char);
memory = (char*) malloc (mem_len); memory = (char*) malloc (mem_len);
if (memory == nullptr){ if (memory == nullptr){
throw sls::RuntimeError("Could not allocate memory for fifos"); throw sls::RuntimeError("Could not allocate memory for fifos");
} }
memset(memory, 0, mem_len); memset(memory, 0, mem_len);
FILE_LOG(logDEBUG) << "Memory Allocated " << index << ": " << mem_len << " bytes"; int pagesize = getpagesize();
for (size_t i = 0; i < mem_len; i += pagesize) {
strcpy(memory + i, "memory");
}
FILE_LOG(logDEBUG) << "Memory Allocated " << index << ": " << (double)mem_len/(double)(1024 * 1024) << " MB";
{ //push free addresses into fifoFree fifo { //push free addresses into fifoFree fifo
char* buffer = memory; char* buffer = memory;

View File

@ -193,10 +193,10 @@ void Implementation::SetupFifoStructure() {
} }
FILE_LOG(logINFO) << "Memory Allocated Per Fifo: " FILE_LOG(logINFO) << "Memory Allocated Per Fifo: "
<< (((generalData->imageSize) + << (double)(((size_t)(generalData->imageSize) +
(generalData->fifoBufferHeaderSize)) * (size_t)(generalData->fifoBufferHeaderSize)) *
fifoDepth) (size_t)fifoDepth) / (double)(1024 * 1024)
<< " bytes"; << " MB";
FILE_LOG(logINFO) << numThreads << " Fifo structure(s) reconstructed"; FILE_LOG(logINFO) << numThreads << " Fifo structure(s) reconstructed";
} }

View File

@ -14,11 +14,12 @@
#include <syscall.h> #include <syscall.h>
#include <unistd.h> //usleep #include <unistd.h> //usleep
#include <memory> #include <memory>
#include <semaphore.h>
bool keeprunning; sem_t semaphore;
void sigInterruptHandler(int p){ void sigInterruptHandler(int p){
keeprunning = false; sem_post(&semaphore);
} }
/** Define Colors to print data call back in different colors for different recievers */ /** Define Colors to print data call back in different colors for different recievers */
@ -65,7 +66,8 @@ void GetData(char* metadata, char* datapointer, uint32_t datasize, void* p){
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
keeprunning = true; sem_init(&semaphore,1,0);
FILE_LOG(logINFOBLUE) << "Created [ Tid: " << syscall(SYS_gettid) << " ]"; FILE_LOG(logINFOBLUE) << "Created [ Tid: " << syscall(SYS_gettid) << " ]";
// Catch signal SIGINT to close files and call destructors properly // Catch signal SIGINT to close files and call destructors properly
@ -136,8 +138,8 @@ int main(int argc, char *argv[]) {
//receiver->registerCallBackRawDataReady(rawDataReadyCallBack,NULL); //receiver->registerCallBackRawDataReady(rawDataReadyCallBack,NULL);
FILE_LOG(logINFO) << "[ Press \'Ctrl+c\' to exit ]"; FILE_LOG(logINFO) << "[ Press \'Ctrl+c\' to exit ]";
while(keeprunning) sem_wait(&semaphore);
pause(); sem_destroy(&semaphore);
FILE_LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]"; FILE_LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]";
FILE_LOG(logINFO) << "Exiting Receiver"; FILE_LOG(logINFO) << "Exiting Receiver";
return 0; return 0;

View File

@ -29,6 +29,7 @@ It is linked in manual/manual-api from slsReceiverSoftware/include ]
#include <sys/wait.h> //wait #include <sys/wait.h> //wait
#include <syscall.h> //tid #include <syscall.h> //tid
#include <unistd.h> //usleep #include <unistd.h> //usleep
#include <semaphore.h>
using namespace std; using namespace std;
@ -36,15 +37,14 @@ using namespace std;
#define PRINT_IN_COLOR(c,f, ...) printf ("\033[%dm" f RESET, 30 + c+1, ##__VA_ARGS__) #define PRINT_IN_COLOR(c,f, ...) printf ("\033[%dm" f RESET, 30 + c+1, ##__VA_ARGS__)
/** Variable is true to continue running, set to false upon interrupt */ sem_t semaphore;
bool keeprunning;
/** /**
* Control+C Interrupt Handler * Control+C Interrupt Handler
* Sets the variable keeprunning to false, to let all the processes know to exit properly * to let all the processes know to exit properly
*/ */
void sigInterruptHandler(int p){ void sigInterruptHandler(int p){
keeprunning = false; sem_post(&semaphore);
} }
/** /**
@ -165,7 +165,7 @@ int main(int argc, char *argv[]) {
int numReceivers = 1; int numReceivers = 1;
int startTCPPort = 1954; int startTCPPort = 1954;
int withCallback = 0; int withCallback = 0;
keeprunning = true; sem_init(&semaphore,1,0);
/** - get number of receivers and start tcp port from command line arguments */ /** - get number of receivers and start tcp port from command line arguments */
if ( (argc != 4) || (!sscanf(argv[1],"%d", &startTCPPort)) || (!sscanf(argv[2],"%d", &numReceivers)) || (!sscanf(argv[3],"%d", &withCallback)) ) if ( (argc != 4) || (!sscanf(argv[1],"%d", &startTCPPort)) || (!sscanf(argv[2],"%d", &numReceivers)) || (!sscanf(argv[3],"%d", &withCallback)) )
@ -238,9 +238,9 @@ int main(int argc, char *argv[]) {
else if (withCallback == 2) receiver->registerCallBackRawDataModifyReady(GetData,nullptr); else if (withCallback == 2) receiver->registerCallBackRawDataModifyReady(GetData,nullptr);
} }
/** - as long as keeprunning is true (changes with Ctrl+C) */ /** - as long as no Ctrl+C */
while(keeprunning) sem_wait(&semaphore);
pause(); sem_destroy(&semaphore);
cprintf(BLUE,"Exiting Child Process [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); cprintf(BLUE,"Exiting Child Process [ Tid: %ld ]\n", (long)syscall(SYS_gettid));
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
break; break;