mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 01:58:00 +02:00
client specifies index of receiver returned error, skeleton of including clientinterface in receiver
This commit is contained in:
@ -11,7 +11,10 @@
|
||||
|
||||
|
||||
|
||||
ClientInterface::ClientInterface(MySocketTCP *socket):dataSocket(socket){}
|
||||
ClientInterface::ClientInterface(MySocketTCP *socket, int n, std::string t):
|
||||
mySocket(socket),
|
||||
index(n),
|
||||
type(t){}
|
||||
|
||||
|
||||
|
||||
@ -24,173 +27,169 @@ int ClientInterface::SendString(int fnum, char retval[], char arg[]){
|
||||
char mess[MAX_STR_LENGTH];
|
||||
memset(mess, 0, MAX_STR_LENGTH);
|
||||
|
||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
dataSocket->SendDataOnly(arg,MAX_STR_LENGTH);
|
||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
mySocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
mySocket->SendDataOnly(arg,MAX_STR_LENGTH);
|
||||
mySocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret==slsDetectorDefs::FAIL){
|
||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
cprintf(RED, "Receiver returned error: %s", mess);
|
||||
mySocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
cprintf(RED, "%s %d returned error: %s", type.c_str(), index, mess);
|
||||
}
|
||||
if(strstr(mess,"Unrecognized Function")==NULL)
|
||||
dataSocket->ReceiveDataOnly(retval,MAX_STR_LENGTH);
|
||||
mySocket->ReceiveDataOnly(retval,MAX_STR_LENGTH);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int ClientInterface::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];
|
||||
memset(mess, 0, MAX_STR_LENGTH);
|
||||
|
||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
dataSocket->SendDataOnly(arg,sizeof(args));
|
||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
mySocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
mySocket->SendDataOnly(arg,sizeof(args));
|
||||
mySocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret==slsDetectorDefs::FAIL){
|
||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
cprintf(RED, "Receiver returned error: %s", mess);
|
||||
mySocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
cprintf(RED, "%s %d returned error: %s", type.c_str(), index, mess);
|
||||
}
|
||||
else
|
||||
dataSocket->ReceiveDataOnly(retval,MAX_STR_LENGTH);
|
||||
mySocket->ReceiveDataOnly(retval,MAX_STR_LENGTH);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int ClientInterface::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);
|
||||
|
||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
dataSocket->SendDataOnly(&arg,sizeof(arg));
|
||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
mySocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
mySocket->SendDataOnly(&arg,sizeof(arg));
|
||||
mySocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret==slsDetectorDefs::FAIL){
|
||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
cprintf(RED, "Receiver returned error: %s", mess);
|
||||
mySocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
cprintf(RED, "%s %d returned error: %s", type.c_str(), index, mess);
|
||||
}
|
||||
if(strstr(mess,"Unrecognized Function")==NULL)
|
||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
mySocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int ClientInterface::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);
|
||||
|
||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
mySocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
mySocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret==slsDetectorDefs::FAIL){
|
||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
cprintf(RED, "Receiver returned error: %s", mess);
|
||||
mySocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
cprintf(RED, "%s %d returned error: %s", type.c_str(), index, mess);
|
||||
}
|
||||
if(strstr(mess,"Unrecognized Function")==NULL)
|
||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
mySocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int ClientInterface::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);
|
||||
|
||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
dataSocket->SendDataOnly(&arg,sizeof(arg));
|
||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
mySocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
mySocket->SendDataOnly(&arg,sizeof(arg));
|
||||
mySocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret==slsDetectorDefs::FAIL){
|
||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
cprintf(RED, "Receiver returned error: %s", mess);
|
||||
mySocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
cprintf(RED, "%s %d returned error: %s", type.c_str(), index, mess);
|
||||
}
|
||||
if(strstr(mess,"Unrecognized Function")==NULL)
|
||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
mySocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int ClientInterface::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);
|
||||
|
||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
dataSocket->SendDataOnly(arg,sizeof(args));
|
||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
mySocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
mySocket->SendDataOnly(arg,sizeof(args));
|
||||
mySocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret==slsDetectorDefs::FAIL){
|
||||
dataSocket->ReceiveDataOnly(mess,MAX_STR_LENGTH);
|
||||
cprintf(RED, "Receiver returned error: %s", mess);
|
||||
mySocket->ReceiveDataOnly(mess,MAX_STR_LENGTH);
|
||||
cprintf(RED, "%s %d returned error: %s", type.c_str(), index, mess);
|
||||
}
|
||||
if(strstr(mess,"Unrecognized Function")==NULL)
|
||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
mySocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int ClientInterface::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];
|
||||
memset(mess, 0, MAX_STR_LENGTH);
|
||||
|
||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
dataSocket->SendDataOnly(arg,sizeof(args));
|
||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
mySocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
mySocket->SendDataOnly(arg,sizeof(args));
|
||||
mySocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret==slsDetectorDefs::FAIL){
|
||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
cprintf(RED, "Receiver returned error: %s", mess);
|
||||
mySocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
cprintf(RED, "%s %d returned error: %s", type.c_str(), index, mess);
|
||||
}
|
||||
if(strstr(mess,"Unrecognized Function")==NULL)
|
||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
mySocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int ClientInterface::getInt(int fnum, int64_t &retval){
|
||||
int ClientInterface::GetInt(int fnum, int64_t &retval){
|
||||
int ret = slsDetectorDefs::FAIL;
|
||||
|
||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
|
||||
mySocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
mySocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
mySocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int ClientInterface::getLastClientIP(int fnum, char retval[]){
|
||||
int ClientInterface::GetLastClientIP(int fnum, char retval[]){
|
||||
int ret = slsDetectorDefs::FAIL;
|
||||
|
||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
dataSocket->ReceiveDataOnly(retval,INET_ADDRSTRLEN);
|
||||
|
||||
mySocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
mySocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
mySocket->ReceiveDataOnly(retval,INET_ADDRSTRLEN);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int ClientInterface::executeFunction(int fnum,char mess[]){
|
||||
int ClientInterface::ExecuteFunction(int fnum,char mess[]){
|
||||
int ret = slsDetectorDefs::FAIL;
|
||||
memset(mess, 0, MAX_STR_LENGTH);
|
||||
|
||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
mySocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
mySocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret==slsDetectorDefs::FAIL){
|
||||
dataSocket->ReceiveDataOnly(mess,MAX_STR_LENGTH);
|
||||
cprintf(RED, "Receiver returned error: %s", mess);
|
||||
mySocket->ReceiveDataOnly(mess,MAX_STR_LENGTH);
|
||||
cprintf(RED, "%s %d returned error: %s", type.c_str(), index, mess);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -198,18 +197,18 @@ int ClientInterface::executeFunction(int fnum,char mess[]){
|
||||
|
||||
|
||||
|
||||
int ClientInterface::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);
|
||||
|
||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
dataSocket->SendDataOnly(&n,sizeof(n));
|
||||
dataSocket->SendDataOnly(roiLimits,n * sizeof(slsReceiverDefs::ROI));
|
||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
mySocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
mySocket->SendDataOnly(&n,sizeof(n));
|
||||
mySocket->SendDataOnly(roiLimits,n * sizeof(slsReceiverDefs::ROI));
|
||||
mySocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret==slsDetectorDefs::FAIL){
|
||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
cprintf(RED, "Receiver returned error: %s", mess);
|
||||
mySocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
cprintf(RED, "%s %d returned error: %s", type.c_str(), index, mess);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
|
||||
/**
|
||||
* @short the ClientInterface class is the interface between the client and the receiver/detector
|
||||
* @short the ClientInterface class is the interface between the client and the server
|
||||
*/
|
||||
|
||||
|
||||
@ -17,9 +17,10 @@ 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(MySocketTCP *socket);
|
||||
|
||||
ClientInterface(MySocketTCP *socket, int n=-1, std::string t="");
|
||||
|
||||
/**
|
||||
* destructor
|
||||
@ -30,11 +31,10 @@ public:
|
||||
* Set the datasocket
|
||||
* @param socket the data socket
|
||||
*/
|
||||
void SetSocket(MySocketTCP *socket){dataSocket=socket;};
|
||||
|
||||
void SetSocket(MySocketTCP *socket){mySocket=socket;};
|
||||
|
||||
/**
|
||||
* Send a string to receiver
|
||||
* Send a string to server
|
||||
* @param fnum function enum to determine what parameter
|
||||
* @param retval return value
|
||||
* @param arg value to send
|
||||
@ -43,78 +43,74 @@ public:
|
||||
int SendString(int fnum, char retval[], char arg[]);
|
||||
|
||||
/**
|
||||
* Send a string to receiver
|
||||
* Send a string to server
|
||||
* @param fnum function enum to send udp ip and udp port
|
||||
* @param retval return value receiver mac
|
||||
* @param retval return value server mac
|
||||
* @param arg value to send
|
||||
* \returns success of operation
|
||||
*/
|
||||
int sendUDPDetails(int fnum, char retval[], char arg[3][MAX_STR_LENGTH]);
|
||||
|
||||
int SendUDPDetails(int fnum, char retval[], char arg[3][MAX_STR_LENGTH]);
|
||||
|
||||
/**
|
||||
* Send an integer to receiver
|
||||
* Send an integer to server
|
||||
* @param fnum function enum to determine what parameter
|
||||
* @param retval return value
|
||||
* @param arg value to send
|
||||
* \returns success of operation
|
||||
*/
|
||||
int sendInt(int fnum, int &retval, int arg);
|
||||
int SendInt(int fnum, int &retval, int arg);
|
||||
|
||||
/**
|
||||
* Get an integer value from receiver
|
||||
* Get an integer value from server
|
||||
* @param fnum function enum to determine what parameter
|
||||
* @param retval return value
|
||||
* \returns success of operation
|
||||
*/
|
||||
int getInt(int fnum, int &retval);
|
||||
int GetInt(int fnum, int &retval);
|
||||
|
||||
/**
|
||||
* Send an integer to receiver
|
||||
* Send an integer to server
|
||||
* @param fnum function enum to determine what parameter
|
||||
* @param retval return value
|
||||
* @param arg value to send
|
||||
* \returns success of operation
|
||||
*/
|
||||
int sendInt(int fnum, int64_t &retval, int64_t arg);
|
||||
|
||||
int SendInt(int fnum, int64_t &retval, int64_t arg);
|
||||
|
||||
/**
|
||||
* Send an integer to receiver
|
||||
* Send an integer to server
|
||||
* @param fnum function enum to determine what parameter
|
||||
* @param retval return value
|
||||
* @param arg values to send
|
||||
* @param mess message returned
|
||||
* \returns success of operation
|
||||
*/
|
||||
int sendIntArray(int fnum, int64_t &retval, int64_t arg[2],char mess[]);
|
||||
|
||||
int SendIntArray(int fnum, int64_t &retval, int64_t arg[2],char mess[]);
|
||||
|
||||
/**
|
||||
* Send an integer to receiver
|
||||
* Send an integer to server
|
||||
* @param fnum function enum to determine what parameter
|
||||
* @param retval return value
|
||||
* @param arg values to send
|
||||
* \returns success of operation
|
||||
*/
|
||||
int sendIntArray(int fnum, int &retval, int arg[2]);
|
||||
int SendIntArray(int fnum, int &retval, int arg[2]);
|
||||
|
||||
/**
|
||||
* Get an integer value from receiver
|
||||
* Get an integer value from server
|
||||
* @param fnum function enum to determine what parameter
|
||||
* @param retval return value
|
||||
* \returns success of operation
|
||||
*/
|
||||
int getInt(int fnum, int64_t &retval);
|
||||
int GetInt(int fnum, int64_t &retval);
|
||||
|
||||
/**
|
||||
* Get last client ip connected to receiver
|
||||
* Get last client ip connected to server
|
||||
* @param fnum function enum to get last client up
|
||||
* @param retval return value
|
||||
* \returns success of operation
|
||||
*/
|
||||
int getLastClientIP(int fnum, char retval[]);
|
||||
|
||||
int GetLastClientIP(int fnum, char retval[]);
|
||||
|
||||
/**
|
||||
* Send a function number to execute function
|
||||
@ -122,17 +118,16 @@ public:
|
||||
* @param mess return error message
|
||||
* \returns success of operation
|
||||
*/
|
||||
int executeFunction(int fnum,char mess[]);
|
||||
int ExecuteFunction(int fnum,char mess[]);
|
||||
|
||||
/**
|
||||
* Send an integer to receiver
|
||||
* Send an integer to server
|
||||
* @param fnum function enum to determine what parameter
|
||||
* @param n number of ROIs to send
|
||||
* @param roiLimits ROI structure
|
||||
* \returns success of operation
|
||||
*/
|
||||
int sendROI(int fnum, int n, slsReceiverDefs::ROI roiLimits[]);
|
||||
|
||||
int SendROI(int fnum, int n, slsReceiverDefs::ROI roiLimits[]);
|
||||
|
||||
|
||||
private:
|
||||
@ -140,7 +135,13 @@ private:
|
||||
/**
|
||||
* socket for data acquisition
|
||||
*/
|
||||
MySocketTCP *dataSocket;
|
||||
MySocketTCP *mySocket;
|
||||
|
||||
/** index for debugging purposes */
|
||||
int index;
|
||||
|
||||
/** string for type to differentiate between Detector & Receiver in printouts */
|
||||
std::string type;
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user