From 78bfc9d0a5c99f169b30808c26d2409fa94ab659 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Wed, 10 Oct 2018 11:43:35 +0200 Subject: [PATCH 1/3] insignificant, renamed recieverInterface to have a capital letter in class name --- slsDetectorSoftware/CMakeLists.txt | 6 ++-- slsDetectorSoftware/Makefile | 4 +-- .../ReceiverInterface.cpp} | 28 +++++++++---------- .../ReceiverInterface.h} | 21 +++++--------- .../slsDetector/slsDetector.cpp | 4 +-- slsDetectorSoftware/slsDetector/slsDetector.h | 4 +-- 6 files changed, 30 insertions(+), 37 deletions(-) rename slsDetectorSoftware/{slsReceiverInterface/receiverInterface.cpp => ReceiverInterface/ReceiverInterface.cpp} (85%) rename slsDetectorSoftware/{slsReceiverInterface/receiverInterface.h => ReceiverInterface/ReceiverInterface.h} (89%) diff --git a/slsDetectorSoftware/CMakeLists.txt b/slsDetectorSoftware/CMakeLists.txt index 67da57b2d..c13083b0e 100644 --- a/slsDetectorSoftware/CMakeLists.txt +++ b/slsDetectorSoftware/CMakeLists.txt @@ -4,7 +4,7 @@ set(SOURCES slsDetector/slsDetectorUsers.cpp slsDetector/slsDetectorCommand.cpp slsDetector/slsDetector.cpp - slsReceiverInterface/receiverInterface.cpp + ReceiverInterface/ReceiverInterface.cpp ../slsSupportLib/include/utilities.cpp ) @@ -16,7 +16,7 @@ include_directories( multiSlsDetector sharedMemory slsDetector -slsReceiverInterface +ReceiverInterface ../slsSupportLib/include ) @@ -52,7 +52,7 @@ set(PUBLICHEADERS slsDetector/slsDetectorUsers.h slsDetector/detectorData.h multiSlsDetector/multiSlsDetector.h - slsReceiverInterface/receiverInterface.h + ReceiverInterface/ReceiverInterface.h ) set_target_properties(slsDetectorShared PROPERTIES LIBRARY_OUTPUT_NAME SlsDetector diff --git a/slsDetectorSoftware/Makefile b/slsDetectorSoftware/Makefile index 3e21793aa..71eae4559 100644 --- a/slsDetectorSoftware/Makefile +++ b/slsDetectorSoftware/Makefile @@ -9,14 +9,14 @@ CFLAGS= -g -DC_ONLY -fPIC DFLAGS= -g -DDACS_INT -INCLUDES?= -I../slsSupportLib/include -IslsDetector -ImultiSlsDetector -IslsReceiverInterface -IsharedMemory I$(ASM) +INCLUDES?= -I../slsSupportLib/include -IslsDetector -ImultiSlsDetector -IReceiverInterface -IsharedMemory I$(ASM) #EPICSFLAGS=-D EPICS -I/usr/local/epics/base/include/ -I /usr/local/epics/base/include/os/Linux/ -L /usr/local/epics/base/lib/$(EPICS_HOST_ARCH) -Wl,-R/usr/local/epics/base/lib/$(EPICS_HOST_ARCH) -lca -lCom LIBZMQDIR = ../slsSupportLib/include LIBZMQ = -L$(LIBZMQDIR) -Wl,-rpath=$(LIBZMQDIR) -lzmq -SRC_CLNT= slsDetector/slsDetectorCommand.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp slsReceiverInterface/receiverInterface.cpp slsDetector/slsDetectorUsers.cpp sharedMemory/SharedMemory.cpp ../slsSupportLib/include/utilities.cpp +SRC_CLNT= slsDetector/slsDetectorCommand.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp ReceiverInterface/ReceiverInterface.cpp slsDetector/slsDetectorUsers.cpp sharedMemory/SharedMemory.cpp ../slsSupportLib/include/utilities.cpp DEPSINCLUDES = ../slsSupportLib/include/sls_receiver_defs.h ../slsSupportLib/include/sls_receiver_funcs.h ../slsSupportLib/include/ansi.h ../slsSupportLib/include/sls_detector_defs.h ../slsSupportLib/include/sls_detector_funcs.h ../slsSupportLib/include/error_defs.h slsDetector/slsDetectorBase.h slsDetector/detectorData.h sharedMemory/SharedMemory.h ../slsSupportLib/include/sls_receiver_exceptions.h ../slsSupportLib/include/versionAPI.h ../slsSupportLib/include/utilities.h ../slsSupportLib/include/container_utils.h diff --git a/slsDetectorSoftware/slsReceiverInterface/receiverInterface.cpp b/slsDetectorSoftware/ReceiverInterface/ReceiverInterface.cpp similarity index 85% rename from slsDetectorSoftware/slsReceiverInterface/receiverInterface.cpp rename to slsDetectorSoftware/ReceiverInterface/ReceiverInterface.cpp index 6173d4185..c9aa7d631 100644 --- a/slsDetectorSoftware/slsReceiverInterface/receiverInterface.cpp +++ b/slsDetectorSoftware/ReceiverInterface/ReceiverInterface.cpp @@ -1,4 +1,4 @@ -#include "receiverInterface.h" +#include "ReceiverInterface.h" #include @@ -11,15 +11,15 @@ -receiverInterface::receiverInterface(MySocketTCP *socket):dataSocket(socket){} +ReceiverInterface::ReceiverInterface(MySocketTCP *socket):dataSocket(socket){} -receiverInterface::~receiverInterface(){} +ReceiverInterface::~ReceiverInterface(){} -int receiverInterface::sendString(int fnum, char retval[], char arg[]){ +int ReceiverInterface::sendString(int fnum, char retval[], char arg[]){ int ret = slsDetectorDefs::FAIL; char mess[MAX_STR_LENGTH]; memset(mess, 0, MAX_STR_LENGTH); @@ -39,7 +39,7 @@ int receiverInterface::sendString(int fnum, char retval[], char arg[]){ -int receiverInterface::sendUDPDetails(int fnum, char retval[], char arg[3][MAX_STR_LENGTH]){ +int ReceiverInterface::sendUDPDetails(int fnum, char retval[], char arg[3][MAX_STR_LENGTH]){ char args[3][MAX_STR_LENGTH]; int ret = slsDetectorDefs::FAIL; char mess[MAX_STR_LENGTH]; @@ -59,7 +59,7 @@ int receiverInterface::sendUDPDetails(int fnum, char retval[], char arg[3][MAX_S } -int receiverInterface::sendInt(int fnum, int &retval, int arg){ +int ReceiverInterface::sendInt(int fnum, int &retval, int arg){ int ret = slsDetectorDefs::FAIL; char mess[MAX_STR_LENGTH]; memset(mess, 0, MAX_STR_LENGTH); @@ -79,7 +79,7 @@ int receiverInterface::sendInt(int fnum, int &retval, int arg){ -int receiverInterface::getInt(int fnum, int &retval){ +int ReceiverInterface::getInt(int fnum, int &retval){ int ret = slsDetectorDefs::FAIL; char mess[MAX_STR_LENGTH]; memset(mess, 0, MAX_STR_LENGTH); @@ -98,7 +98,7 @@ int receiverInterface::getInt(int fnum, int &retval){ -int receiverInterface::sendInt(int fnum, int64_t &retval, int64_t arg){ +int ReceiverInterface::sendInt(int fnum, int64_t &retval, int64_t arg){ int ret = slsDetectorDefs::FAIL; char mess[MAX_STR_LENGTH]; memset(mess, 0, MAX_STR_LENGTH); @@ -118,7 +118,7 @@ int receiverInterface::sendInt(int fnum, int64_t &retval, int64_t arg){ -int receiverInterface::sendIntArray(int fnum, int64_t &retval, int64_t arg[2], char mess[]){ +int ReceiverInterface::sendIntArray(int fnum, int64_t &retval, int64_t arg[2], char mess[]){ int64_t args[2]; int ret = slsDetectorDefs::FAIL; memset(mess, 0, MAX_STR_LENGTH); @@ -138,7 +138,7 @@ int receiverInterface::sendIntArray(int fnum, int64_t &retval, int64_t arg[2], c -int receiverInterface::sendIntArray(int fnum, int &retval, int arg[2]){ +int ReceiverInterface::sendIntArray(int fnum, int &retval, int arg[2]){ int args[2]; int ret = slsDetectorDefs::FAIL; char mess[MAX_STR_LENGTH]; @@ -159,7 +159,7 @@ int receiverInterface::sendIntArray(int fnum, int &retval, int arg[2]){ -int receiverInterface::getInt(int fnum, int64_t &retval){ +int ReceiverInterface::getInt(int fnum, int64_t &retval){ int ret = slsDetectorDefs::FAIL; dataSocket->SendDataOnly(&fnum,sizeof(fnum)); @@ -170,7 +170,7 @@ int receiverInterface::getInt(int fnum, int64_t &retval){ } -int receiverInterface::getLastClientIP(int fnum, char retval[]){ +int ReceiverInterface::getLastClientIP(int fnum, char retval[]){ int ret = slsDetectorDefs::FAIL; dataSocket->SendDataOnly(&fnum,sizeof(fnum)); @@ -182,7 +182,7 @@ int receiverInterface::getLastClientIP(int fnum, char retval[]){ -int receiverInterface::executeFunction(int fnum,char mess[]){ +int ReceiverInterface::executeFunction(int fnum,char mess[]){ int ret = slsDetectorDefs::FAIL; memset(mess, 0, MAX_STR_LENGTH); @@ -198,7 +198,7 @@ int receiverInterface::executeFunction(int fnum,char mess[]){ -int receiverInterface::sendROI(int fnum, int n, slsReceiverDefs::ROI roiLimits[]) { +int ReceiverInterface::sendROI(int fnum, int n, slsReceiverDefs::ROI roiLimits[]) { int ret = slsDetectorDefs::FAIL; char mess[MAX_STR_LENGTH]; memset(mess, 0, MAX_STR_LENGTH); diff --git a/slsDetectorSoftware/slsReceiverInterface/receiverInterface.h b/slsDetectorSoftware/ReceiverInterface/ReceiverInterface.h similarity index 89% rename from slsDetectorSoftware/slsReceiverInterface/receiverInterface.h rename to slsDetectorSoftware/ReceiverInterface/ReceiverInterface.h index f188c8da8..28a6c4854 100644 --- a/slsDetectorSoftware/slsReceiverInterface/receiverInterface.h +++ b/slsDetectorSoftware/ReceiverInterface/ReceiverInterface.h @@ -1,23 +1,16 @@ +#pragma once - -#ifndef SLS_RECEIVER_INTERFACE_H -#define SLS_RECEIVER_INTERFACE_H - #include "sls_detector_defs.h" #include "MySocketTCP.h" - /** - * - * @short the slsReceiverInterface class is the interface between the sls detector and the sls receiver - * @author Dhanya Maliakal - * @version 0.1alpha + * @short the ReceiverInterface class is the interface between the client and the receiver */ -class receiverInterface{ +class ReceiverInterface{ public: @@ -25,13 +18,13 @@ public: * (default) constructor * @param socket tcp socket between client and receiver */ - receiverInterface(MySocketTCP *socket); + ReceiverInterface(MySocketTCP *socket); /** * destructor */ - virtual ~receiverInterface(); + virtual ~ReceiverInterface(); /** * Set the datasocket @@ -140,7 +133,7 @@ public: */ int sendROI(int fnum, int n, slsReceiverDefs::ROI roiLimits[]); - //here one should implement the funcs listed in + private: @@ -151,4 +144,4 @@ private: }; -#endif + diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 11900da9a..de92c003b 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -2,7 +2,7 @@ #include "multiSlsDetector.h" #include "sls_receiver_exceptions.h" #include "SharedMemory.h" -#include "receiverInterface.h" +#include "ReceiverInterface.h" #include "gitInfoLib.h" #include "versionAPI.h" #include "slsDetectorCommand.h" @@ -590,7 +590,7 @@ void slsDetector::initializeMembers() { delete thisReceiver; thisReceiver = 0; } - thisReceiver = new receiverInterface(dataSocket); + thisReceiver = new ReceiverInterface(dataSocket); } diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index 759ff8d8b..6b68e90ea 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -14,7 +14,7 @@ class multiSlsDetector; class SharedMemory; -class receiverInterface; +class ReceiverInterface; #define SLS_SHMVERSION 0x181005 #define NCHIPSMAX 10 @@ -1884,7 +1884,7 @@ private: sharedSlsDetector *thisDetector; /** receiver interface */ - receiverInterface *thisReceiver; + ReceiverInterface *thisReceiver; /** socket for control commands */ MySocketTCP *controlSocket; From 5e7e7d3c339f2dfe55457cd352924e6420b0110b Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Wed, 10 Oct 2018 12:00:47 +0200 Subject: [PATCH 2/3] moved client interface to common folder as receiver wills tart using it as well --- slsDetectorSoftware/CMakeLists.txt | 6 ++-- slsDetectorSoftware/Makefile | 4 +-- .../slsDetector/slsDetector.cpp | 16 +++++------ slsDetectorSoftware/slsDetector/slsDetector.h | 4 +-- .../include/ClientInterface.cpp | 28 +++++++++---------- .../include/ClientInterface.h | 12 ++++---- 6 files changed, 34 insertions(+), 36 deletions(-) rename slsDetectorSoftware/ReceiverInterface/ReceiverInterface.cpp => slsSupportLib/include/ClientInterface.cpp (83%) rename slsDetectorSoftware/ReceiverInterface/ReceiverInterface.h => slsSupportLib/include/ClientInterface.h (91%) diff --git a/slsDetectorSoftware/CMakeLists.txt b/slsDetectorSoftware/CMakeLists.txt index c13083b0e..8686bf2e3 100644 --- a/slsDetectorSoftware/CMakeLists.txt +++ b/slsDetectorSoftware/CMakeLists.txt @@ -4,7 +4,7 @@ set(SOURCES slsDetector/slsDetectorUsers.cpp slsDetector/slsDetectorCommand.cpp slsDetector/slsDetector.cpp - ReceiverInterface/ReceiverInterface.cpp + ../slsSupportLib/include/ClientInterface.cpp ../slsSupportLib/include/utilities.cpp ) @@ -16,8 +16,6 @@ include_directories( multiSlsDetector sharedMemory slsDetector -ReceiverInterface -../slsSupportLib/include ) add_library(slsDetectorStatic STATIC @@ -52,7 +50,7 @@ set(PUBLICHEADERS slsDetector/slsDetectorUsers.h slsDetector/detectorData.h multiSlsDetector/multiSlsDetector.h - ReceiverInterface/ReceiverInterface.h + ../slsSupportLib/include/ClientInterface.h ) set_target_properties(slsDetectorShared PROPERTIES LIBRARY_OUTPUT_NAME SlsDetector diff --git a/slsDetectorSoftware/Makefile b/slsDetectorSoftware/Makefile index 71eae4559..104107a22 100644 --- a/slsDetectorSoftware/Makefile +++ b/slsDetectorSoftware/Makefile @@ -9,14 +9,14 @@ CFLAGS= -g -DC_ONLY -fPIC DFLAGS= -g -DDACS_INT -INCLUDES?= -I../slsSupportLib/include -IslsDetector -ImultiSlsDetector -IReceiverInterface -IsharedMemory I$(ASM) +INCLUDES?= -I../slsSupportLib/include -IslsDetector -ImultiSlsDetector -I../slsSupportLib/include -IsharedMemory I$(ASM) #EPICSFLAGS=-D EPICS -I/usr/local/epics/base/include/ -I /usr/local/epics/base/include/os/Linux/ -L /usr/local/epics/base/lib/$(EPICS_HOST_ARCH) -Wl,-R/usr/local/epics/base/lib/$(EPICS_HOST_ARCH) -lca -lCom LIBZMQDIR = ../slsSupportLib/include LIBZMQ = -L$(LIBZMQDIR) -Wl,-rpath=$(LIBZMQDIR) -lzmq -SRC_CLNT= slsDetector/slsDetectorCommand.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp ReceiverInterface/ReceiverInterface.cpp slsDetector/slsDetectorUsers.cpp sharedMemory/SharedMemory.cpp ../slsSupportLib/include/utilities.cpp +SRC_CLNT= slsDetector/slsDetectorCommand.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp ../slsSupportLib/include/ReceiverInterface.cpp slsDetector/slsDetectorUsers.cpp sharedMemory/SharedMemory.cpp ../slsSupportLib/include/utilities.cpp DEPSINCLUDES = ../slsSupportLib/include/sls_receiver_defs.h ../slsSupportLib/include/sls_receiver_funcs.h ../slsSupportLib/include/ansi.h ../slsSupportLib/include/sls_detector_defs.h ../slsSupportLib/include/sls_detector_funcs.h ../slsSupportLib/include/error_defs.h slsDetector/slsDetectorBase.h slsDetector/detectorData.h sharedMemory/SharedMemory.h ../slsSupportLib/include/sls_receiver_exceptions.h ../slsSupportLib/include/versionAPI.h ../slsSupportLib/include/utilities.h ../slsSupportLib/include/container_utils.h diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index de92c003b..7ad201c57 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -2,7 +2,7 @@ #include "multiSlsDetector.h" #include "sls_receiver_exceptions.h" #include "SharedMemory.h" -#include "ReceiverInterface.h" +#include "ClientInterface.h" #include "gitInfoLib.h" #include "versionAPI.h" #include "slsDetectorCommand.h" @@ -590,7 +590,7 @@ void slsDetector::initializeMembers() { delete thisReceiver; thisReceiver = 0; } - thisReceiver = new ReceiverInterface(dataSocket); + thisReceiver = new ClientInterface(dataSocket); } @@ -3928,7 +3928,7 @@ std::string slsDetector::setReceiverStreamingIP(std::string sourceIP) { std::endl; #endif if (connectData() == OK){ - ret=thisReceiver->sendString(fnum,retval,arg); + ret=thisReceiver->SendString(fnum,retval,arg); disconnectData(); } if(ret==FAIL) { @@ -3960,7 +3960,7 @@ std::string slsDetector::setAdditionalJsonHeader(std::string jsonheader) { std::cout << "Sending additional json header " << arg << std::endl; #endif if (connectData() == OK){ - ret=thisReceiver->sendString(fnum,retval,arg); + ret=thisReceiver->SendString(fnum,retval,arg); disconnectData(); } if(ret==FAIL) { @@ -5894,7 +5894,7 @@ int slsDetector::setReceiverTCPSocket(std::string const name, int const receiver //check if it connects if (retval!=FAIL) { checkReceiverOnline(); - thisReceiver->setSocket(dataSocket); + thisReceiver->SetSocket(dataSocket); // check for version compatibility switch (thisDetector->myDetectorType) { case EIGER: @@ -6168,7 +6168,7 @@ void slsDetector::setDetectorHostname() { thisDetector->hostname << std::endl; #endif if (connectData() == OK){ - ret=thisReceiver->sendString(fnum,retval,thisDetector->hostname); + ret=thisReceiver->SendString(fnum,retval,thisDetector->hostname); disconnectData(); } if((ret==FAIL) || (strcmp(retval,thisDetector->hostname))) @@ -6199,7 +6199,7 @@ std::string slsDetector::setFilePath(std::string s) { std::cout << "Sending file path to receiver " << arg << std::endl; #endif if (connectData() == OK){ - ret=thisReceiver->sendString(fnum,retval,arg); + ret=thisReceiver->SendString(fnum,retval,arg); disconnectData(); } if(ret!=FAIL){ @@ -6240,7 +6240,7 @@ std::string slsDetector::setFileName(std::string s) { std::cout << "Sending file name to receiver " << arg << std::endl; #endif if (connectData() == OK){ - ret=thisReceiver->sendString(fnum,retval,arg); + ret=thisReceiver->SendString(fnum,retval,arg); disconnectData(); } if (ret == FAIL) diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index 6b68e90ea..368b34d52 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -14,7 +14,7 @@ class multiSlsDetector; class SharedMemory; -class ReceiverInterface; +class ClientInterface; #define SLS_SHMVERSION 0x181005 #define NCHIPSMAX 10 @@ -1884,7 +1884,7 @@ private: sharedSlsDetector *thisDetector; /** receiver interface */ - ReceiverInterface *thisReceiver; + ClientInterface *thisReceiver; /** socket for control commands */ MySocketTCP *controlSocket; diff --git a/slsDetectorSoftware/ReceiverInterface/ReceiverInterface.cpp b/slsSupportLib/include/ClientInterface.cpp similarity index 83% rename from slsDetectorSoftware/ReceiverInterface/ReceiverInterface.cpp rename to slsSupportLib/include/ClientInterface.cpp index c9aa7d631..fbf7d4e08 100644 --- a/slsDetectorSoftware/ReceiverInterface/ReceiverInterface.cpp +++ b/slsSupportLib/include/ClientInterface.cpp @@ -1,4 +1,4 @@ -#include "ReceiverInterface.h" +#include "ClientInterface.h" #include @@ -11,15 +11,15 @@ -ReceiverInterface::ReceiverInterface(MySocketTCP *socket):dataSocket(socket){} +ClientInterface::ClientInterface(MySocketTCP *socket):dataSocket(socket){} -ReceiverInterface::~ReceiverInterface(){} +ClientInterface::~ClientInterface(){} -int ReceiverInterface::sendString(int fnum, char retval[], char arg[]){ +int ClientInterface::SendString(int fnum, char retval[], char arg[]){ int ret = slsDetectorDefs::FAIL; char mess[MAX_STR_LENGTH]; memset(mess, 0, MAX_STR_LENGTH); @@ -39,7 +39,7 @@ int ReceiverInterface::sendString(int fnum, char retval[], char arg[]){ -int ReceiverInterface::sendUDPDetails(int fnum, char retval[], char arg[3][MAX_STR_LENGTH]){ +int ClientInterface::sendUDPDetails(int fnum, char retval[], char arg[3][MAX_STR_LENGTH]){ char args[3][MAX_STR_LENGTH]; int ret = slsDetectorDefs::FAIL; char mess[MAX_STR_LENGTH]; @@ -59,7 +59,7 @@ int ReceiverInterface::sendUDPDetails(int fnum, char retval[], char arg[3][MAX_S } -int ReceiverInterface::sendInt(int fnum, int &retval, int arg){ +int ClientInterface::sendInt(int fnum, int &retval, int arg){ int ret = slsDetectorDefs::FAIL; char mess[MAX_STR_LENGTH]; memset(mess, 0, MAX_STR_LENGTH); @@ -79,7 +79,7 @@ int ReceiverInterface::sendInt(int fnum, int &retval, int arg){ -int ReceiverInterface::getInt(int fnum, int &retval){ +int ClientInterface::getInt(int fnum, int &retval){ int ret = slsDetectorDefs::FAIL; char mess[MAX_STR_LENGTH]; memset(mess, 0, MAX_STR_LENGTH); @@ -98,7 +98,7 @@ int ReceiverInterface::getInt(int fnum, int &retval){ -int ReceiverInterface::sendInt(int fnum, int64_t &retval, int64_t arg){ +int ClientInterface::sendInt(int fnum, int64_t &retval, int64_t arg){ int ret = slsDetectorDefs::FAIL; char mess[MAX_STR_LENGTH]; memset(mess, 0, MAX_STR_LENGTH); @@ -118,7 +118,7 @@ int ReceiverInterface::sendInt(int fnum, int64_t &retval, int64_t arg){ -int ReceiverInterface::sendIntArray(int fnum, int64_t &retval, int64_t arg[2], char mess[]){ +int ClientInterface::sendIntArray(int fnum, int64_t &retval, int64_t arg[2], char mess[]){ int64_t args[2]; int ret = slsDetectorDefs::FAIL; memset(mess, 0, MAX_STR_LENGTH); @@ -138,7 +138,7 @@ int ReceiverInterface::sendIntArray(int fnum, int64_t &retval, int64_t arg[2], c -int ReceiverInterface::sendIntArray(int fnum, int &retval, int arg[2]){ +int ClientInterface::sendIntArray(int fnum, int &retval, int arg[2]){ int args[2]; int ret = slsDetectorDefs::FAIL; char mess[MAX_STR_LENGTH]; @@ -159,7 +159,7 @@ int ReceiverInterface::sendIntArray(int fnum, int &retval, int arg[2]){ -int ReceiverInterface::getInt(int fnum, int64_t &retval){ +int ClientInterface::getInt(int fnum, int64_t &retval){ int ret = slsDetectorDefs::FAIL; dataSocket->SendDataOnly(&fnum,sizeof(fnum)); @@ -170,7 +170,7 @@ int ReceiverInterface::getInt(int fnum, int64_t &retval){ } -int ReceiverInterface::getLastClientIP(int fnum, char retval[]){ +int ClientInterface::getLastClientIP(int fnum, char retval[]){ int ret = slsDetectorDefs::FAIL; dataSocket->SendDataOnly(&fnum,sizeof(fnum)); @@ -182,7 +182,7 @@ int ReceiverInterface::getLastClientIP(int fnum, char retval[]){ -int ReceiverInterface::executeFunction(int fnum,char mess[]){ +int ClientInterface::executeFunction(int fnum,char mess[]){ int ret = slsDetectorDefs::FAIL; memset(mess, 0, MAX_STR_LENGTH); @@ -198,7 +198,7 @@ int ReceiverInterface::executeFunction(int fnum,char mess[]){ -int ReceiverInterface::sendROI(int fnum, int n, slsReceiverDefs::ROI roiLimits[]) { +int ClientInterface::sendROI(int fnum, int n, slsReceiverDefs::ROI roiLimits[]) { int ret = slsDetectorDefs::FAIL; char mess[MAX_STR_LENGTH]; memset(mess, 0, MAX_STR_LENGTH); diff --git a/slsDetectorSoftware/ReceiverInterface/ReceiverInterface.h b/slsSupportLib/include/ClientInterface.h similarity index 91% rename from slsDetectorSoftware/ReceiverInterface/ReceiverInterface.h rename to slsSupportLib/include/ClientInterface.h index 28a6c4854..ec5d94b50 100644 --- a/slsDetectorSoftware/ReceiverInterface/ReceiverInterface.h +++ b/slsSupportLib/include/ClientInterface.h @@ -6,11 +6,11 @@ /** - * @short the ReceiverInterface class is the interface between the client and the receiver + * @short the ClientInterface class is the interface between the client and the receiver/detector */ -class ReceiverInterface{ +class ClientInterface{ public: @@ -18,19 +18,19 @@ public: * (default) constructor * @param socket tcp socket between client and receiver */ - ReceiverInterface(MySocketTCP *socket); + ClientInterface(MySocketTCP *socket); /** * destructor */ - virtual ~ReceiverInterface(); + virtual ~ClientInterface(); /** * Set the datasocket * @param socket the data socket */ - void setSocket(MySocketTCP *socket){dataSocket=socket;}; + void SetSocket(MySocketTCP *socket){dataSocket=socket;}; /** @@ -40,7 +40,7 @@ public: * @param arg value to send * \returns success of operation */ - int sendString(int fnum, char retval[], char arg[]); + int SendString(int fnum, char retval[], char arg[]); /** * Send a string to receiver From b981fe78efa71c770b2a16ce763bb396e88dd88b Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Wed, 10 Oct 2018 12:23:55 +0200 Subject: [PATCH 3/3] connected command to execute command in receiver pc --- .../multiSlsDetector/multiSlsDetector.cpp | 12 +++++++++ .../multiSlsDetector/multiSlsDetector.h | 9 +++++++ .../slsDetector/slsDetector.cpp | 26 +++++++++++++++++++ slsDetectorSoftware/slsDetector/slsDetector.h | 8 ++++++ .../slsDetector/slsDetectorCommand.cpp | 16 +++++++++++- .../src/slsReceiverTCPIPInterface.cpp | 5 ++-- 6 files changed, 73 insertions(+), 3 deletions(-) diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index ed2e44a0a..739bf18cb 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -2724,6 +2724,18 @@ int multiSlsDetector::exitReceiver(int detPos) { } +int multiSlsDetector::execReceiverCommand(std::string cmd, int detPos) { + // single + if (detPos >= 0) { + return detectors[detPos]->execReceiverCommand(cmd); + } + + // multi + auto r = parallelCall(&slsDetector::execReceiverCommand, cmd); + return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; +} + + std::string multiSlsDetector::getFilePath(int detPos) { // single if (detPos >= 0) { diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index fb66a14db..46a4a1787 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -1229,6 +1229,15 @@ public: */ int exitReceiver(int detPos = -1); + /** + * Executes a system command on the receiver server + * e.g. mount an nfs disk, reboot and returns answer etc. + * @param cmd command to be executed + * @param detPos -1 for all detectors in list or specific detector position + * @returns OK or FAIL + */ + int execReceiverCommand(std::string cmd, int detPos = -1); + /** * Returns output file directory * @param detPos -1 for all detectors in list or specific detector position diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 7ad201c57..822f8fb41 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -5990,6 +5990,30 @@ int slsDetector::exitReceiver() { } +int slsDetector::execReceiverCommand(std::string cmd) { + + int fnum=F_EXEC_RECEIVER_COMMAND; + int ret=FAIL; + char arg[MAX_STR_LENGTH]; + memset(arg,0,sizeof(arg)); + char retval[MAX_STR_LENGTH]; + memset(retval,0, sizeof(retval)); + + strcpy(arg,cmd.c_str()); + + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { +#ifdef VERBOSE + std::cout << "Sending to receiver the command: " << arg << std::endl; +#endif + if (connectData() == OK){ + ret=thisReceiver->SendString(fnum,retval,arg); + disconnectData(); + } + } + return ret; +} + + int slsDetector::updateReceiverNoWait() { @@ -7506,3 +7530,5 @@ int slsDetector::writeSettingsFile(std::string fname, sls_detector_module mod, } + + diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index 368b34d52..d280c6682 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -1377,6 +1377,14 @@ public: */ int exitReceiver(); + /** + * Executes a system command on the receiver server + * e.g. mount an nfs disk, reboot and returns answer etc. + * @param cmd command to be executed + * @returns OK or FAIL + */ + int execReceiverCommand(std::string cmd); + /** updates the shared memory receiving the data from the detector (without asking and closing the connection /returns OK diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index 68823a18c..ffc9de7a3 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -112,6 +112,13 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdExitServer; ++i; + /*! \page test + - rx_execcommand Executes a command on the receiver server. Don't use it!!!! + */ + descrToFuncMap[i].m_pFuncName="rx_execcommand";//OK + descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdExitServer; + ++i; + /*! \page test - flippeddatay [i] enables/disables data being flipped across y axis. 1 enables, 0 disables. Not implemented. */ @@ -2437,7 +2444,13 @@ string slsDetectorCommand::cmdExitServer(int narg, char *args[], int action, int if(myDet->execCommand(std::string(args[1]), detPos)==OK) return string("Command executed successfully\n"); else - + return string("Command failed\n"); + } + else if (cmd=="rx_execcommand"){ + myDet->setReceiverOnline(ONLINE_FLAG, detPos); + if(myDet->execReceiverCommand(std::string(args[1]), detPos)==OK) + return string("Command executed successfully\n"); + else return string("Command failed\n"); } else return("cannot decode command\n"); @@ -2451,6 +2464,7 @@ string slsDetectorCommand::helpExitServer(int action){ os << string("exitserver \t shuts down all the detector servers. Don't use it!!!!\n"); os << string("exitreceiver \t shuts down all the receiver servers.\n"); os << string("execcommand \t executes command in detector server. Don't use it if you do not know what you are doing.\n"); + os << string("rx_execcommand \t executes command in receiver server. Don't use it if you do not know what you are doing.\n"); return os.str(); } diff --git a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp index 6130ded10..a7886f341 100644 --- a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp +++ b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp @@ -426,7 +426,7 @@ int slsReceiverTCPIPInterface::exec_command() { sysret=system(cmd); //should be replaced by popen if (sysret == 0) { - sprintf(mess,"Succeeded\n"); + ret = OK; } else { ret = FAIL; sprintf(mess,"Executing Command failed\n"); @@ -436,7 +436,8 @@ int slsReceiverTCPIPInterface::exec_command() { // send answer mySock->SendDataOnly(&ret,sizeof(ret)); - mySock->SendDataOnly(mess,MAX_STR_LENGTH); + if (ret == FAIL) + mySock->SendDataOnly(mess,MAX_STR_LENGTH); // return ok/fail return ret;