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

View File

@ -196,10 +196,9 @@ class BinaryFileStatic {
* @param fd file pointer
* @param owenable overwrite enable
* @param fname complete file name
* @param filebuffersize file buffer size
* @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 (NULL == (fd = fopen((const char *) fname.c_str(), "wx"))){
@ -210,8 +209,8 @@ class BinaryFileStatic {
fd = 0;
throw sls::RuntimeError("Could not create file " + fname);
}
//setting file buffer size to 16mb
setvbuf(fd,NULL,_IOFBF,filebuffersize);
//setting to no file buffering
setvbuf(fd, NULL, _IONBF, 0);
}
};

View File

@ -49,7 +49,7 @@ void BinaryFile::CreateFile() {
currentFileName = BinaryFileStatic::CreateFileName(*filePath, *fileNamePrefix, *fileIndex,
subFileIndex, *detIndex, *numUnitsPerDetector, index);
BinaryFileStatic::CreateDataFile(filefd, *overWriteEnable, currentFileName, FILE_BUFFER_SIZE);
BinaryFileStatic::CreateDataFile(filefd, *overWriteEnable, currentFileName);
if(!(*silentMode)) {
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);
fifoStream = new CircularFifo<char>(fifoDepth);
//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);
if (memory == nullptr){
throw sls::RuntimeError("Could not allocate memory for fifos");
}
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
char* buffer = memory;

View File

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

View File

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

View File

@ -29,6 +29,7 @@ It is linked in manual/manual-api from slsReceiverSoftware/include ]
#include <sys/wait.h> //wait
#include <syscall.h> //tid
#include <unistd.h> //usleep
#include <semaphore.h>
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__)
/** Variable is true to continue running, set to false upon interrupt */
bool keeprunning;
sem_t semaphore;
/**
* 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){
keeprunning = false;
sem_post(&semaphore);
}
/**
@ -165,7 +165,7 @@ int main(int argc, char *argv[]) {
int numReceivers = 1;
int startTCPPort = 1954;
int withCallback = 0;
keeprunning = true;
sem_init(&semaphore,1,0);
/** - 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)) )
@ -238,9 +238,9 @@ int main(int argc, char *argv[]) {
else if (withCallback == 2) receiver->registerCallBackRawDataModifyReady(GetData,nullptr);
}
/** - as long as keeprunning is true (changes with Ctrl+C) */
while(keeprunning)
pause();
/** - as long as no Ctrl+C */
sem_wait(&semaphore);
sem_destroy(&semaphore);
cprintf(BLUE,"Exiting Child Process [ Tid: %ld ]\n", (long)syscall(SYS_gettid));
exit(EXIT_SUCCESS);
break;