From ab7e63c20feaaf5f24cc9ce37651a48e4b21ce0c Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Wed, 8 Aug 2018 15:43:29 +0200 Subject: [PATCH] Moved sls_detector_exceptions to sls_receiver_exceptions & its consequences --- slsDetectorSoftware/CMakeLists.txt | 3 +-- slsDetectorSoftware/Makefile | 2 +- .../multiSlsDetector/multiSlsDetector.cpp | 2 +- .../multiSlsDetector/multiSlsDetectorClient.h | 2 +- .../sharedMemory/SharedMemory.cpp | 6 +++--- slsDetectorSoftware/slsDetector/slsDetector.cpp | 2 +- slsReceiverSoftware/CMakeLists.txt | 2 +- slsReceiverSoftware/Makefile | 2 +- slsReceiverSoftware/include/MySocketTCP.h | 2 +- .../include/sls_receiver_exceptions.h | 16 +++++++++++++++- 10 files changed, 26 insertions(+), 13 deletions(-) rename slsDetectorSoftware/commonFiles/sls_detector_exceptions.h => slsReceiverSoftware/include/sls_receiver_exceptions.h (61%) diff --git a/slsDetectorSoftware/CMakeLists.txt b/slsDetectorSoftware/CMakeLists.txt index 939d833e9..67d0416aa 100644 --- a/slsDetectorSoftware/CMakeLists.txt +++ b/slsDetectorSoftware/CMakeLists.txt @@ -59,7 +59,6 @@ set(PUBLICHEADERS commonFiles/sls_detector_defs.h commonFiles/sls_detector_funcs.h commonFiles/error_defs.h - commonFiles/sls_detector_exceptions.h commonFiles/versionAPI.h sharedMemory/SharedMemory.h slsDetector/slsDetectorUtils.h @@ -78,7 +77,7 @@ set(PUBLICHEADERS slsDetectorAnalysis/fileIOStatic.h multiSlsDetector/multiSlsDetector.h slsReceiverInterface/receiverInterface.h - + ../slsReceiverSoftware/include/sls_receiver_exceptions.h ) set_target_properties(slsDetectorShared PROPERTIES LIBRARY_OUTPUT_NAME SlsDetector diff --git a/slsDetectorSoftware/Makefile b/slsDetectorSoftware/Makefile index 1e2fa98ff..1be7ccc6f 100644 --- a/slsDetectorSoftware/Makefile +++ b/slsDetectorSoftware/Makefile @@ -17,7 +17,7 @@ LIBZMQDIR = ../slsReceiverSoftware/include LIBZMQ = -L$(LIBZMQDIR) -Wl,-rpath=$(LIBZMQDIR) -lzmq SRC_CLNT=slsDetectorAnalysis/fileIO.cpp usersFunctions/usersFunctions.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp slsDetectorAnalysis/angularConversion.cpp slsDetectorAnalysis/angularConversionStatic.cpp slsDetectorAnalysis/energyConversion.cpp slsDetector/slsDetectorActions.cpp slsDetectorAnalysis/postProcessing.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp slsDetectorAnalysis/postProcessingFuncs.cpp slsReceiverInterface/receiverInterface.cpp slsDetector/slsDetectorUsers.cpp threadFiles/CondVar.cpp threadFiles/Mutex.cpp threadFiles/ThreadPool.cpp sharedMemory/SharedMemory.cpp #../slsReceiverSoftware/MySocketTCP/MySocketTCP.cpp -DEPSINCLUDES = $(LIBZMQDIR)/sls_receiver_defs.h $(LIBZMQDIR)/sls_receiver_funcs.h $(LIBZMQDIR)/ansi.h commonFiles/sls_detector_defs.h commonFiles/sls_detector_funcs.h commonFiles/error_defs.h slsDetector/slsDetectorBase.h slsDetectorAnalysis/angCalLogClass.h slsDetectorAnalysis/angleConversionConstant.h slsDetectorAnalysis/badChannelCorrections.h slsDetectorAnalysis/detectorData.h slsDetectorAnalysis/enCalLogClass.h slsDetectorAnalysis/fileIOStatic.h slsDetectorAnalysis/movingStat.h slsDetectorAnalysis/runningStat.h slsDetectorAnalysis/single_photon_hit.h threadFiles/Global.h threadFiles/Task.h usersFunctions/angleFunction.h sharedMemory/SharedMemory.h commonFiles/sls_detector_exceptions.h commonFiles/versionAPI.h +DEPSINCLUDES = $(LIBZMQDIR)/sls_receiver_defs.h $(LIBZMQDIR)/sls_receiver_funcs.h $(LIBZMQDIR)/ansi.h commonFiles/sls_detector_defs.h commonFiles/sls_detector_funcs.h commonFiles/error_defs.h slsDetector/slsDetectorBase.h slsDetectorAnalysis/angCalLogClass.h slsDetectorAnalysis/angleConversionConstant.h slsDetectorAnalysis/badChannelCorrections.h slsDetectorAnalysis/detectorData.h slsDetectorAnalysis/enCalLogClass.h slsDetectorAnalysis/fileIOStatic.h slsDetectorAnalysis/movingStat.h slsDetectorAnalysis/runningStat.h slsDetectorAnalysis/single_photon_hit.h threadFiles/Global.h threadFiles/Task.h usersFunctions/angleFunction.h sharedMemory/SharedMemory.h $(LIBZMQDIR)/sls_receiver_exceptions.h commonFiles/versionAPI.h diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 697e1b0b6..d8e5fb3a5 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -11,7 +11,7 @@ ID: $Id$ #include "multiSlsDetector.h" #include "SharedMemory.h" #include "slsDetector.h" -#include "sls_detector_exceptions.h" +#include "sls_receiver_exceptions.h" #include "ThreadPool.h" #include "ZmqSocket.h" #include "multiSlsDetectorClient.h" diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetectorClient.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetectorClient.h index 040267cc1..7250d63a3 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetectorClient.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetectorClient.h @@ -4,7 +4,7 @@ #include "multiSlsDetector.h" #include "multiSlsDetectorCommand.h" -#include "sls_detector_exceptions.h" +#include "sls_receiver_exceptions.h" #include diff --git a/slsDetectorSoftware/sharedMemory/SharedMemory.cpp b/slsDetectorSoftware/sharedMemory/SharedMemory.cpp index 19803da96..45176ef3b 100644 --- a/slsDetectorSoftware/sharedMemory/SharedMemory.cpp +++ b/slsDetectorSoftware/sharedMemory/SharedMemory.cpp @@ -1,5 +1,5 @@ #include "SharedMemory.h" -#include "sls_detector_exceptions.h" +#include "sls_receiver_exceptions.h" #include "ansi.h" #include @@ -122,14 +122,14 @@ void* SharedMemory::MapSharedMemory(size_t sz) { std::string SharedMemory::ConstructSharedMemoryName(int multiId, int slsId) { // using environment path - string sEnvPath = ""; + std::string sEnvPath = ""; char* envpath = getenv(SHM_ENV_NAME); if (envpath != NULL) { sEnvPath.assign(envpath); sEnvPath.insert(0,"_"); } - stringstream ss; + std::stringstream ss; if (slsId < 0) ss << SHM_MULTI_PREFIX << multiId << sEnvPath; else diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index a0506e93f..403610a81 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -1,6 +1,6 @@ #include "slsDetector.h" #include "multiSlsDetector.h" -#include "sls_detector_exceptions.h" +#include "sls_receiver_exceptions.h" #include "SharedMemory.h" #include "receiverInterface.h" #include "gitInfoLib.h" diff --git a/slsReceiverSoftware/CMakeLists.txt b/slsReceiverSoftware/CMakeLists.txt index 0cfbc8819..7fdc5d042 100644 --- a/slsReceiverSoftware/CMakeLists.txt +++ b/slsReceiverSoftware/CMakeLists.txt @@ -69,7 +69,7 @@ set(PUBLICHEADERS include/MySocketTCP.h include/genericSocket.h include/logger.h - + include/sls_receiver_exceptions.h ) diff --git a/slsReceiverSoftware/Makefile b/slsReceiverSoftware/Makefile index 4fe92b278..655d0c1dc 100644 --- a/slsReceiverSoftware/Makefile +++ b/slsReceiverSoftware/Makefile @@ -26,7 +26,7 @@ LIBZMQ = -L$(LIBZMQDIR) -Wl,-rpath=$(LIBZMQDIR) -lzmq SRC_CLNT = MySocketTCP.cpp ThreadObject.cpp Listener.cpp DataProcessor.cpp DataStreamer.cpp Fifo.cpp File.cpp BinaryFile.cpp UDPInterface.cpp UDPBaseImplementation.cpp UDPStandardImplementation.cpp slsReceiverTCPIPInterface.cpp slsReceiver.cpp slsReceiverUsers.cpp utilities.cpp -DEPSINCLUDES = $(INCDIR)/ansi.h $(INCDIR)/sls_receiver_defs.h $(INCDIR)/sls_receiver_funcs.h $(INCDIR)/GeneralData.h $(INCDIR)/circularFifo.h $(INCDIR)/genericSocket.h $(INCDIR)/logger.h $(INCDIR)/receiver_defs.h $(INCDIR)/UDPInterface.h $(INCDIR)/utilities.h $(INCDIR)/ZmqSocket.h $(INCDIR)/BinaryFileStatic.h $(INCDIR)/HDF5FileStatic.h +DEPSINCLUDES = $(INCDIR)/ansi.h $(INCDIR)/sls_receiver_defs.h $(INCDIR)/sls_receiver_funcs.h $(INCDIR)/GeneralData.h $(INCDIR)/circularFifo.h $(INCDIR)/genericSocket.h $(INCDIR)/logger.h $(INCDIR)/receiver_defs.h $(INCDIR)/UDPInterface.h $(INCDIR)/utilities.h $(INCDIR)/ZmqSocket.h $(INCDIR)/BinaryFileStatic.h $(INCDIR)/HDF5FileStatic.h $(INCDIR)/sls_receiver_exceptions.h ifeq ($(HDF5),yes) diff --git a/slsReceiverSoftware/include/MySocketTCP.h b/slsReceiverSoftware/include/MySocketTCP.h index 7846967a7..a3f6ea285 100644 --- a/slsReceiverSoftware/include/MySocketTCP.h +++ b/slsReceiverSoftware/include/MySocketTCP.h @@ -43,7 +43,7 @@ class MySocketTCP: public genericSocket { public: MySocketTCP(const char* const host_ip_or_name, unsigned short int const port_number): genericSocket(host_ip_or_name, port_number,TCP), last_keep_connection_open_action_was_a_send(0){setPacketSize(TCP_PACKET_SIZE);}; // sender (client): where to? ip MySocketTCP(unsigned short int const port_number):genericSocket(port_number,TCP), last_keep_connection_open_action_was_a_send(0) {setPacketSize(TCP_PACKET_SIZE);}; // receiver (server) local no need for ip - + virtual ~MySocketTCP(){}; //The following two functions will connectioned->send/receive->disconnect int SendData(void* buf,int length);//length in characters diff --git a/slsDetectorSoftware/commonFiles/sls_detector_exceptions.h b/slsReceiverSoftware/include/sls_receiver_exceptions.h similarity index 61% rename from slsDetectorSoftware/commonFiles/sls_detector_exceptions.h rename to slsReceiverSoftware/include/sls_receiver_exceptions.h index f49bf359d..32d4b011c 100644 --- a/slsDetectorSoftware/commonFiles/sls_detector_exceptions.h +++ b/slsReceiverSoftware/include/sls_receiver_exceptions.h @@ -1,6 +1,6 @@ #pragma once /************************************************ - * @file sls_detector_exceptions.h + * @file sls_receiver_exceptions.h * @short exceptions defined ***********************************************/ /** @@ -23,3 +23,17 @@ public: ThreadpoolException() {} string GetMessage() const { return "Threadpool Failed";}; }; + +struct SocketException : public std::exception { +public: + SocketException() {} + std::string GetMessage() const { return "Socket Failed";}; +}; + + +struct SamePortSocketException : public SocketException { +public: + SamePortSocketException() {} + std::string GetMessage() const { return "Socket Failed";}; +}; +