mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-21 00:58:01 +02:00
changed constructor
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
|
||||
#include "sls_detector_defs.h"
|
||||
#include "MySocketTCP.h"
|
||||
#include "ClientSocket.h"
|
||||
|
||||
|
||||
/**
|
||||
@ -20,18 +21,13 @@ public:
|
||||
* @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(MySocketTCP *socket, int n=-1, std::string t="");
|
||||
ClientInterface(int n, sls::ClientSocket&& s);
|
||||
|
||||
/**
|
||||
* destructor
|
||||
*/
|
||||
virtual ~ClientInterface() = default;
|
||||
|
||||
/**
|
||||
* Set the datasocket
|
||||
* @param socket the data socket
|
||||
*/
|
||||
void SetSocket(MySocketTCP *socket);
|
||||
|
||||
/**
|
||||
* Receive ret, mess or retval from Server
|
||||
@ -58,95 +54,18 @@ public:
|
||||
char* mess = 0);
|
||||
|
||||
|
||||
/** only Receiver
|
||||
* Server sends result to client (also set ret to force_update if different clients)
|
||||
* @param update true if one must update if different clients, else false
|
||||
* @param ret success of operation
|
||||
* @param retval pointer to result
|
||||
* @param retvalSize size of result
|
||||
* @param mess message
|
||||
* @returns success of operation
|
||||
*/
|
||||
int Server_SendResult(bool update, int ret, void* retval, int retvalSize, char* mess = 0);
|
||||
|
||||
/** only Receiver
|
||||
* Server receives arguments and checks if base object is null (if checkbase is true)
|
||||
* checking base object is null (for receiver only when it has not been configured yet)
|
||||
* @param ret pointer to success of operation
|
||||
* @param mess message
|
||||
* @param arg pointer to argument
|
||||
* @param sizeofArg size of argument
|
||||
* @param checkbase if true, checks if base object is null and sets ret and mess accordingly
|
||||
* @param base pointer to base object
|
||||
* @returns fail if socket crashes while reading arguments, else fail
|
||||
*/
|
||||
int Server_ReceiveArg(int& ret, char* mess, void* arg, int sizeofArg,bool checkbase=false, void* base=NULL);
|
||||
|
||||
/** only Receiver
|
||||
* Server verifies if it is unlocked,
|
||||
* sets and prints appropriate message if it is locked and different clients
|
||||
* @param ret pointer to success
|
||||
* @param mess message
|
||||
* @param lockstatus status of lock
|
||||
* @returns success of operaton
|
||||
*/
|
||||
int Server_VerifyLock(int& ret, char* mess, int lockstatus);
|
||||
|
||||
/** only Receiver
|
||||
* Server verifies if it is unlocked and idle,
|
||||
* sets and prints appropriate message if it is locked and different clients
|
||||
* @param ret pointer to success
|
||||
* @param mess message
|
||||
* @param lockstatus status of lock
|
||||
* @param status status of server
|
||||
* @param fnum function number for error message
|
||||
* @returns success of operaton
|
||||
*/
|
||||
int Server_VerifyLockAndIdle(int& ret, char* mess, int lockstatus, slsDetectorDefs::runStatus status, int fnum);
|
||||
|
||||
/** only Receiver
|
||||
* Server sets and prints error message for null object error (receiver only)
|
||||
* @param ret pointer to success that will be set to FAIL
|
||||
* @param mess message
|
||||
*/
|
||||
void Server_NullObjectError(int& ret, char* mess);
|
||||
|
||||
/** only Receiver
|
||||
* Servers prints error message for socket crash when reading
|
||||
* @returns always FAIL
|
||||
*/
|
||||
int Server_SocketCrash();
|
||||
|
||||
/** only Receiver
|
||||
* Servers sets and prints error message for locked server
|
||||
* @param ret pointer to success that will be set to FAIL
|
||||
* @param mess message
|
||||
* @returns success of operaton
|
||||
*/
|
||||
int Server_LockedError(int& ret, char* mess);
|
||||
|
||||
/** only Receiver
|
||||
* Servers sets and prints error message for server not being idle
|
||||
* @param ret pointer to success that will be set to FAIL
|
||||
* @param mess message
|
||||
* @param fnum function number for error message
|
||||
* @returns success of operaton
|
||||
*/
|
||||
int Server_NotIdleError(int& ret, char* mess, int fnum);
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* socket for data acquisition
|
||||
*/
|
||||
MySocketTCP *mySocket;
|
||||
sls::ClientSocket socket_;
|
||||
|
||||
/** index for client debugging purposes */
|
||||
int index;
|
||||
|
||||
/** string for type to differentiate between Detector & Receiver in printouts */
|
||||
std::string type;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -10,8 +10,9 @@ namespace sls{
|
||||
class ClientSocket: public DataSocket{
|
||||
public:
|
||||
ClientSocket(const std::string& hostname, uint16_t port_number);
|
||||
int connect();
|
||||
private:
|
||||
|
||||
struct sockaddr_in serverAddr {};
|
||||
};
|
||||
|
||||
}; //namespace sls
|
@ -7,7 +7,11 @@ namespace sls {
|
||||
class DataSocket {
|
||||
public:
|
||||
DataSocket(int socketId);
|
||||
|
||||
DataSocket(DataSocket&& move) noexcept;
|
||||
DataSocket& operator=(DataSocket&& move) noexcept;
|
||||
void swap(DataSocket& other) noexcept;
|
||||
DataSocket(DataSocket const&) = delete;
|
||||
DataSocket& operator=(DataSocket const&) = delete;
|
||||
int getSocketId() const{
|
||||
return socketId_;
|
||||
}
|
||||
|
Reference in New Issue
Block a user