Merge branch 'refactor' of github.com:slsdetectorgroup/slsDetectorPackage into refactor

This commit is contained in:
2019-01-16 13:29:11 +01:00
5 changed files with 40 additions and 44 deletions

View File

@ -26,8 +26,12 @@ endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 ") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 ")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=thread") # set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=thread")
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=thread") # set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=thread")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
find_package(Qt4) find_package(Qt4)
find_package(Qwt 6) find_package(Qwt 6)

View File

@ -20,7 +20,7 @@ class multiSlsDetectorClient {
public: public:
multiSlsDetectorClient(int argc, char *argv[], int action, multiSlsDetector *myDetector=NULL) { \ multiSlsDetectorClient(int argc, char *argv[], int action, multiSlsDetector *myDetector=NULL) { \
std::string answer; \ std::string answer; \
multiSlsDetectorCommand *myCmd; \ // multiSlsDetectorCommand *myCmd;
int id = -1, pos = -1, iv = 0; \ int id = -1, pos = -1, iv = 0; \
bool verify = true, update = true; \ bool verify = true, update = true; \
int del = 0; \ int del = 0; \
@ -122,18 +122,19 @@ public:
std::cout << "position is out of bounds." << std::endl; \ std::cout << "position is out of bounds." << std::endl; \
return; \ return; \
} \ } \
// call multi detector command line
myCmd=new multiSlsDetectorCommand(myDetector); \ try {
try { \ // call multi detector command line
answer=myCmd->executeLine(argc, argv, action, pos); \ multiSlsDetectorCommand myCmd(myDetector); \
answer=myCmd.executeLine(argc, argv, action, pos); \
} catch (const SlsDetectorPackageExceptions & e) { \ } catch (const SlsDetectorPackageExceptions & e) { \
/*std::cout << e.GetMessage() << std::endl; */ \ /*std::cout << e.GetMessage() << std::endl; */ \
delete myCmd; \
if (del) delete myDetector; \ if (del) delete myDetector; \
return; \ return; \
} catch (...) { \ } catch (...) { \
std::cout << " caught exception" << std::endl; \ std::cout << " caught exception" << std::endl; \
delete myCmd; \ \
if (del) delete myDetector; \ if (del) delete myDetector; \
return; \ return; \
} \ } \
@ -141,7 +142,7 @@ public:
std::cout << argv[0] << " " ; \ std::cout << argv[0] << " " ; \
} \ } \
std::cout << answer<< std::endl; \ std::cout << answer<< std::endl; \
delete myCmd; \ \
if (del) delete myDetector; \ if (del) delete myDetector; \
}; };

View File

@ -1,5 +1,6 @@
#include "slsDetectorCommand.h" #include "slsDetectorCommand.h"
#include "multiSlsDetector.h" #include "multiSlsDetector.h"
#include "string_utils.h"
#include <cstdlib> #include <cstdlib>
#include <fstream> #include <fstream>

View File

@ -1,46 +1,33 @@
#include "multiSlsDetectorClient.h"
#include "gitInfoLib.h" #include "gitInfoLib.h"
#include "multiSlsDetectorClient.h"
#include <cstdlib>
int main(int argc, char *argv[]) {
#include <stdlib.h> for (int i = 1; i < argc; ++i) {
using namespace std; if (!(strcmp(argv[i], "--version")) || !(strcmp(argv[i], "-v"))) {
int64_t tempval = GITDATE;
int main(int argc, char *argv[]) std::cout << argv[0] << " " << GITBRANCH << " (0x" << std::hex << tempval << ")" << std::endl;
return 0;
{ }
for (int i = 1; i < argc; ++i ) { }
if (!(strcmp (argv[i],"--version")) || !(strcmp (argv[i],"-v"))) {
int64_t tempval = GITDATE;
cout << argv[0] << " " << GITBRANCH << " (0x" << hex << tempval << ")" << endl;
return 0;
}
}
#ifdef PUT #ifdef PUT
int action=slsDetectorDefs::PUT_ACTION; int action = slsDetectorDefs::PUT_ACTION;
#endif #endif
#ifdef GET #ifdef GET
int action=slsDetectorDefs::GET_ACTION; int action = slsDetectorDefs::GET_ACTION;
#endif #endif
#ifdef READOUT #ifdef READOUT
int action=slsDetectorDefs::READOUT_ACTION; int action = slsDetectorDefs::READOUT_ACTION;
#endif #endif
#ifdef HELP #ifdef HELP
int action=slsDetectorDefs::HELP_ACTION; int action = slsDetectorDefs::HELP_ACTION;
#endif #endif
multiSlsDetectorClient *cl; if (argc > 1)
if (argc>1) argv++;
cl=new multiSlsDetectorClient(argc-1, argv+1, action); multiSlsDetectorClient(argc - 1, argv, action);
else
cl=new multiSlsDetectorClient(argc-1, argv, action);
delete cl;
} }

View File

@ -64,9 +64,12 @@ Listener::Listener(int ind, detectorType dtype, Fifo* f, runStatus* s,
Listener::~Listener() { Listener::~Listener() {
if (udpSocket) delete udpSocket; if (udpSocket){
sem_post(&semaphore_socket); delete udpSocket;
sem_destroy(&semaphore_socket); sem_post(&semaphore_socket);
sem_destroy(&semaphore_socket);
}
if (carryOverPacket) delete [] carryOverPacket; if (carryOverPacket) delete [] carryOverPacket;
if (listeningPacket) delete [] listeningPacket; if (listeningPacket) delete [] listeningPacket;
ThreadObject::DestroyThread(); ThreadObject::DestroyThread();