mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-20 02:40:03 +02:00
removed ClientInterface
This commit is contained in:
parent
97dd329a7b
commit
bf0847e967
@ -6,7 +6,7 @@
|
|||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
#include "network_utils.h"
|
#include "network_utils.h"
|
||||||
#include "FixedCapacityContainer.h"
|
#include "FixedCapacityContainer.h"
|
||||||
class ClientInterface;
|
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "slsDetector.h"
|
#include "slsDetector.h"
|
||||||
#include "ClientInterface.h"
|
|
||||||
#include "ClientSocket.h"
|
#include "ClientSocket.h"
|
||||||
#include "ServerInterface.h"
|
#include "ServerInterface.h"
|
||||||
#include "SharedMemory.h"
|
#include "SharedMemory.h"
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
set(SOURCES
|
set(SOURCES
|
||||||
src/ClientInterface.cpp
|
|
||||||
src/CmdLineParser.cpp
|
src/CmdLineParser.cpp
|
||||||
src/string_utils.cpp
|
src/string_utils.cpp
|
||||||
src/file_utils.cpp
|
src/file_utils.cpp
|
||||||
@ -22,7 +21,6 @@ set(PUBLICHEADERS
|
|||||||
include/file_utils.h
|
include/file_utils.h
|
||||||
include/container_utils.h
|
include/container_utils.h
|
||||||
include/string_utils.h
|
include/string_utils.h
|
||||||
include/ClientInterface.h
|
|
||||||
include/MySocketTCP.h
|
include/MySocketTCP.h
|
||||||
include/genericSocket.h
|
include/genericSocket.h
|
||||||
include/logger.h
|
include/logger.h
|
||||||
|
@ -1,70 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
|
|
||||||
#include "sls_detector_defs.h"
|
|
||||||
#include "ClientSocket.h"
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @short the ClientInterface class is the interface between the client and the server
|
|
||||||
*/
|
|
||||||
// Do not overload to make it easier for manual comparison between client and server functions
|
|
||||||
|
|
||||||
class ClientInterface: public virtual slsDetectorDefs{
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* (default) constructor
|
|
||||||
* @param socket tcp socket between client and receiver
|
|
||||||
* @param n for debugging purposes (useful only for client side)
|
|
||||||
* @param t string to identify type (Detector, Receiver) for printouts (useful only for client side)
|
|
||||||
*/
|
|
||||||
ClientInterface(sls::ClientSocket* socket, int n);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* destructor
|
|
||||||
*/
|
|
||||||
virtual ~ClientInterface() = default;
|
|
||||||
|
|
||||||
void SetSocket(sls::ClientSocket *socket){
|
|
||||||
socket_ = socket;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Receive ret, mess or retval from Server
|
|
||||||
* @param ret result of operation
|
|
||||||
* @param mess pointer to message
|
|
||||||
* @param retval pointer to retval
|
|
||||||
* @param sizeOfRetval size of retval
|
|
||||||
*/
|
|
||||||
void Client_Receive(int& ret, char* mess, void* retval, int sizeOfRetval);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send Arguments to server and receives result back
|
|
||||||
* @param fnum function enum to determine what parameter
|
|
||||||
* @param args pointer to arguments
|
|
||||||
* @param sizeOfArgs argument size
|
|
||||||
* @param retval pointer to return value
|
|
||||||
* @param sizeOfRetval return value size
|
|
||||||
* @param mess pointer to message if message required externally
|
|
||||||
* @returns success of operation
|
|
||||||
*/
|
|
||||||
int Client_Send(int fnum,
|
|
||||||
void* args, int sizeOfArgs,
|
|
||||||
void* retval, int sizeOfRetval,
|
|
||||||
char* mess = 0);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* socket for data acquisition
|
|
||||||
*/
|
|
||||||
sls::ClientSocket* socket_;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
|||||||
#include "ClientInterface.h"
|
|
||||||
#include "ClientSocket.h"
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
ClientInterface::ClientInterface(sls::ClientSocket *socket, int n) : socket_(socket){}
|
|
||||||
|
|
||||||
void ClientInterface::Client_Receive(int &ret, char *mess, void *retval, int sizeOfRetval) {
|
|
||||||
// get result of operation
|
|
||||||
socket_->receiveData(reinterpret_cast<char *>(&ret), sizeof(ret));
|
|
||||||
|
|
||||||
bool unrecognizedFunction = false;
|
|
||||||
if (ret == FAIL) {
|
|
||||||
bool created = false;
|
|
||||||
// allocate mess if null
|
|
||||||
if (!mess) {
|
|
||||||
created = true;
|
|
||||||
mess = new char[MAX_STR_LENGTH];
|
|
||||||
memset(mess, 0, MAX_STR_LENGTH);
|
|
||||||
}
|
|
||||||
// get error message
|
|
||||||
socket_->receiveData(mess, MAX_STR_LENGTH);
|
|
||||||
// cprintf(RED, "%s %d returned error: %s", type.c_str(), index, mess);
|
|
||||||
|
|
||||||
// unrecognized function, do not ask for retval
|
|
||||||
if (strstr(mess, "Unrecognized Function") != nullptr)
|
|
||||||
unrecognizedFunction = true;
|
|
||||||
// delete allocated mess
|
|
||||||
if (created)
|
|
||||||
delete[] mess;
|
|
||||||
}
|
|
||||||
// get retval
|
|
||||||
if (!unrecognizedFunction)
|
|
||||||
socket_->receiveData(reinterpret_cast<char *>(retval), sizeOfRetval);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ClientInterface::Client_Send(int fnum, void *args, int sizeOfArgs, void *retval,
|
|
||||||
int sizeOfRetval, char *mess) {
|
|
||||||
int ret = FAIL;
|
|
||||||
socket_->sendData(reinterpret_cast<char *>(&fnum), sizeof(fnum));
|
|
||||||
socket_->sendData(reinterpret_cast<char *>(args), sizeOfArgs);
|
|
||||||
Client_Receive(ret, mess, retval, sizeOfRetval);
|
|
||||||
return ret;
|
|
||||||
}
|
|
@ -1,5 +1,4 @@
|
|||||||
target_sources(tests PRIVATE
|
target_sources(tests PRIVATE
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/test-ClientInterface.cpp
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/test-CmdLineParser.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/test-CmdLineParser.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/test-container_utils.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/test-container_utils.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/test-network_utils.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/test-network_utils.cpp
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
#include "ClientInterface.h"
|
|
||||||
#include "catch.hpp"
|
|
||||||
|
|
||||||
//tests to add
|
|
||||||
//help for all docs
|
|
||||||
//command for all depreciated commands
|
|
||||||
|
|
||||||
TEST_CASE("hopp") {
|
|
||||||
REQUIRE(true);
|
|
||||||
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user