mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 21:37:13 +02:00
client specifies index of receiver returned error, skeleton of including clientinterface in receiver
This commit is contained in:
@ -185,7 +185,7 @@ int slsDetector::checkVersionCompatibility(portType t) {
|
||||
if (connectData() == OK){
|
||||
// ignoring retval
|
||||
int64_t retval = -1;
|
||||
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||
ret=thisReceiver->SendInt(fnum,retval,arg);
|
||||
if (ret==FAIL){
|
||||
setErrorMask((getErrorMask())|(VERSION_COMPATIBILITY));
|
||||
if(strstr(mess,"Unrecognized Function")!=NULL)
|
||||
@ -222,7 +222,7 @@ int64_t slsDetector::getId( idMode mode) {
|
||||
} else if (mode==RECEIVER_VERSION) {
|
||||
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->getInt(fnum2,retval);
|
||||
ret=thisReceiver->GetInt(fnum2,retval);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FORCE_UPDATE)
|
||||
@ -590,7 +590,7 @@ void slsDetector::initializeMembers() {
|
||||
delete thisReceiver;
|
||||
thisReceiver = 0;
|
||||
}
|
||||
thisReceiver = new ClientInterface(dataSocket);
|
||||
thisReceiver = new ClientInterface(dataSocket, detId, "Receiver");
|
||||
}
|
||||
|
||||
|
||||
@ -958,7 +958,7 @@ int slsDetector::setDetectorType(detectorType const type) {
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
int arg = 0;
|
||||
ret=thisReceiver->sendInt(fnum2,arg,(int)thisDetector->myDetectorType);
|
||||
ret=thisReceiver->SendInt(fnum2,arg,(int)thisDetector->myDetectorType);
|
||||
disconnectData();
|
||||
retval = (detectorType)arg;
|
||||
}
|
||||
@ -2761,7 +2761,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) {
|
||||
|
||||
char mess[MAX_STR_LENGTH]="";
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendIntArray(fnum2,retval,args,mess);
|
||||
ret=thisReceiver->SendIntArray(fnum2,retval,args,mess);
|
||||
disconnectData();
|
||||
}
|
||||
if((args[1] != retval)|| (ret==FAIL)){
|
||||
@ -2951,7 +2951,7 @@ int slsDetector::setDynamicRange(int n) {
|
||||
n << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum2,retval1,n);
|
||||
ret=thisReceiver->SendInt(fnum2,retval1,n);
|
||||
disconnectData();
|
||||
}
|
||||
if ((ret==FAIL) || (retval1 != retval)){
|
||||
@ -3531,7 +3531,7 @@ std::string slsDetector::getReceiverRealUDPSocketBufferSize() {
|
||||
std::cout << "Getting real UDP Socket Buffer size to receiver " << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->getInt(fnum,retval);
|
||||
ret=thisReceiver->GetInt(fnum,retval);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FAIL) {
|
||||
@ -3841,7 +3841,7 @@ std::string slsDetector::setReceiverStreamingPort(std::string port) {
|
||||
std::cout << "Sending receiver streaming port to receiver " << arg << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||
ret=thisReceiver->SendInt(fnum,retval,arg);
|
||||
disconnectData();
|
||||
}
|
||||
if (ret==FAIL) {
|
||||
@ -3988,7 +3988,7 @@ std::string slsDetector::setReceiverUDPSocketBufferSize(int udpsockbufsize) {
|
||||
std::cout << "Sending UDP Socket Buffer size to receiver " << arg << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||
ret=thisReceiver->SendInt(fnum,retval,arg);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FAIL) {
|
||||
@ -4101,7 +4101,7 @@ int slsDetector::setUDPConnection() {
|
||||
std::cout << "Setting up UDP Connection for Receiver " << args[0] << "\t" << args[1] << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendUDPDetails(fnum,retval,args);
|
||||
ret=thisReceiver->SendUDPDetails(fnum,retval,args);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret!=FAIL){
|
||||
@ -4472,7 +4472,7 @@ int slsDetector::sendROI(int n,ROI roiLimits[]) {
|
||||
std::cout << "Sending ROI to receiver " << thisDetector->nROI << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendROI(fnum, thisDetector->nROI, thisDetector->roiLimits);
|
||||
ret=thisReceiver->SendROI(fnum, thisDetector->nROI, thisDetector->roiLimits);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FAIL)
|
||||
@ -4586,7 +4586,7 @@ int slsDetector::activate(int const enable) {
|
||||
std::cout << "Activating/Deactivating Receiver: " << arg << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum2,retval,arg);
|
||||
ret=thisReceiver->SendInt(fnum2,retval,arg);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FAIL)
|
||||
@ -4626,7 +4626,7 @@ int slsDetector::setDeactivatedRxrPaddingMode(int padding) {
|
||||
std::cout << "Deactivated Receiver Padding Enable: " << arg << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||
ret=thisReceiver->SendInt(fnum,retval,arg);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FAIL)
|
||||
@ -4675,7 +4675,7 @@ int slsDetector::setFlippedData(dimension d, int value) {
|
||||
|
||||
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendIntArray(fnum,retval,args);
|
||||
ret=thisReceiver->SendIntArray(fnum,retval,args);
|
||||
|
||||
disconnectData();
|
||||
}
|
||||
@ -4745,7 +4745,7 @@ int slsDetector::enableGapPixels(int val) {
|
||||
int arg=val;
|
||||
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||
ret=thisReceiver->SendInt(fnum,retval,arg);
|
||||
disconnectData();
|
||||
}
|
||||
if((arg != retval) || (ret==FAIL)){
|
||||
@ -5932,7 +5932,7 @@ int slsDetector::lockReceiver(int lock) {
|
||||
std::cout << "Locking or Unlocking Receiver " << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||
ret=thisReceiver->SendInt(fnum,retval,arg);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FORCE_UPDATE)
|
||||
@ -5957,7 +5957,7 @@ std::string slsDetector::getReceiverLastClientIP() {
|
||||
std::cout << "Geting Last Client IP connected to Receiver " << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->getLastClientIP(fnum,retval);
|
||||
ret=thisReceiver->GetLastClientIP(fnum,retval);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FORCE_UPDATE)
|
||||
@ -6147,7 +6147,7 @@ void slsDetector::sendMultiDetectorSize() {
|
||||
<< thisDetector->multiSize[1] << ")" << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendIntArray(fnum,retval,thisDetector->multiSize);
|
||||
ret=thisReceiver->SendIntArray(fnum,retval,thisDetector->multiSize);
|
||||
disconnectData();
|
||||
}
|
||||
if((ret==FAIL)){
|
||||
@ -6169,7 +6169,7 @@ void slsDetector::setDetectorId() {
|
||||
std::cout << "Sending detector pos id to Receiver " << detId << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||
ret=thisReceiver->SendInt(fnum,retval,arg);
|
||||
disconnectData();
|
||||
}
|
||||
if((ret==FAIL) || (retval != arg)){
|
||||
@ -6295,7 +6295,7 @@ int slsDetector::setReceiverFramesPerFile(int f) {
|
||||
std::cout << "Sending frames per file to receiver " << arg << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||
ret=thisReceiver->SendInt(fnum,retval,arg);
|
||||
disconnectData();
|
||||
}
|
||||
if (ret == FAIL)
|
||||
@ -6322,7 +6322,7 @@ slsReceiverDefs::frameDiscardPolicy slsDetector::setReceiverFramesDiscardPolicy(
|
||||
std::cout << "Sending frames discard policy to receiver " << arg << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||
ret=thisReceiver->SendInt(fnum,retval,arg);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FAIL)
|
||||
@ -6349,7 +6349,7 @@ int slsDetector::setReceiverPartialFramesPadding(int f) {
|
||||
std::cout << "Sending partial frames enable to receiver " << arg << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||
ret=thisReceiver->SendInt(fnum,retval,arg);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FAIL)
|
||||
@ -6379,7 +6379,7 @@ slsReceiverDefs::fileFormat slsDetector::setFileFormat(fileFormat f) {
|
||||
std::cout << "Sending file format to receiver " << arg << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||
ret=thisReceiver->SendInt(fnum,retval,arg);
|
||||
disconnectData();
|
||||
}
|
||||
if (ret == FAIL)
|
||||
@ -6417,7 +6417,7 @@ int slsDetector::setFileIndex(int i) {
|
||||
std::cout << "Sending file index to receiver " << arg << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||
ret=thisReceiver->SendInt(fnum,retval,arg);
|
||||
disconnectData();
|
||||
}
|
||||
if (ret == FAIL)
|
||||
@ -6452,7 +6452,7 @@ int slsDetector::startReceiver() {
|
||||
#endif
|
||||
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->executeFunction(fnum,mess);
|
||||
ret=thisReceiver->ExecuteFunction(fnum,mess);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FORCE_UPDATE)
|
||||
@ -6483,7 +6483,7 @@ int slsDetector::stopReceiver() {
|
||||
std::cout << "Stopping Receiver " << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->executeFunction(fnum,mess);
|
||||
ret=thisReceiver->ExecuteFunction(fnum,mess);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FORCE_UPDATE)
|
||||
@ -6510,7 +6510,7 @@ slsDetectorDefs::runStatus slsDetector::getReceiverStatus() {
|
||||
std::cout << "Getting Receiver Status" << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->getInt(fnum,retval);
|
||||
ret=thisReceiver->GetInt(fnum,retval);
|
||||
disconnectData();
|
||||
}
|
||||
if(retval!=-1)
|
||||
@ -6535,7 +6535,7 @@ int slsDetector::getFramesCaughtByReceiver() {
|
||||
std::cout << "Getting Frames Caught by Receiver " << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->getInt(fnum,retval);
|
||||
ret=thisReceiver->GetInt(fnum,retval);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FORCE_UPDATE)
|
||||
@ -6563,7 +6563,7 @@ int slsDetector::getReceiverCurrentFrameIndex() {
|
||||
std::cout << "Getting Current Frame Index of Receiver " << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->getInt(fnum,retval);
|
||||
ret=thisReceiver->GetInt(fnum,retval);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FORCE_UPDATE)
|
||||
@ -6586,7 +6586,7 @@ int slsDetector::resetFramesCaught() {
|
||||
std::cout << "Reset Frames Caught by Receiver" << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->executeFunction(fnum,mess);
|
||||
ret=thisReceiver->ExecuteFunction(fnum,mess);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FORCE_UPDATE)
|
||||
@ -6621,7 +6621,7 @@ int slsDetector::enableWriteToFile(int enable) {
|
||||
std::cout << "Sending enable file write to receiver " << arg << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||
ret=thisReceiver->SendInt(fnum,retval,arg);
|
||||
disconnectData();
|
||||
}
|
||||
if (ret == FAIL)
|
||||
@ -6655,7 +6655,7 @@ int slsDetector::overwriteFile(int enable) {
|
||||
std::cout << "Sending enable file write to receiver " << arg << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||
ret=thisReceiver->SendInt(fnum,retval,arg);
|
||||
disconnectData();
|
||||
}
|
||||
if (ret == FAIL)
|
||||
@ -6690,7 +6690,7 @@ int slsDetector::setReceiverStreamingFrequency(int freq) {
|
||||
std::cout << "Sending read frequency to receiver " << arg << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||
ret=thisReceiver->SendInt(fnum,retval,arg);
|
||||
disconnectData();
|
||||
}
|
||||
if((ret == FAIL) || (retval != freq)) {
|
||||
@ -6720,7 +6720,7 @@ int slsDetector::setReceiverStreamingTimer(int time_in_ms) {
|
||||
std::cout << "Sending read timer to receiver " << arg << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||
ret=thisReceiver->SendInt(fnum,retval,arg);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FORCE_UPDATE)
|
||||
@ -6760,7 +6760,7 @@ int slsDetector::enableDataStreamingFromReceiver(int enable) {
|
||||
<< arg << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||
ret=thisReceiver->SendInt(fnum,retval,arg);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FAIL) {
|
||||
@ -6822,7 +6822,7 @@ int slsDetector::enableTenGigabitEthernet(int i) {
|
||||
<< i << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum2,retval,i);
|
||||
ret=thisReceiver->SendInt(fnum2,retval,i);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FAIL)
|
||||
@ -6853,7 +6853,7 @@ int slsDetector::setReceiverFifoDepth(int i) {
|
||||
std::cout<< "Setting Receiver Fifo Depth to " << i << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum,retval,i);
|
||||
ret=thisReceiver->SendInt(fnum,retval,i);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FAIL)
|
||||
@ -6878,7 +6878,7 @@ int slsDetector::setReceiverSilentMode(int i) {
|
||||
std::cout<< "Setting Receiver Silent Mode to " << i << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum,retval,i);
|
||||
ret=thisReceiver->SendInt(fnum,retval,i);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FAIL)
|
||||
@ -6903,7 +6903,7 @@ int slsDetector::restreamStopFromReceiver() {
|
||||
#endif
|
||||
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->executeFunction(fnum,mess);
|
||||
ret=thisReceiver->ExecuteFunction(fnum,mess);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FORCE_UPDATE)
|
||||
|
@ -11,6 +11,7 @@ set(SOURCES
|
||||
src/DataStreamer.cpp
|
||||
src/Fifo.cpp
|
||||
../slsSupportLib/include/utilities.cpp
|
||||
../slsSupportLib/include/ClientInterface.cpp
|
||||
)
|
||||
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "receiver_defs.h"
|
||||
|
||||
class MySocketTCP;
|
||||
class ClientInterface;
|
||||
class slsReceiverImplementation;
|
||||
|
||||
|
||||
@ -365,6 +366,10 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs {
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/** Socket */
|
||||
MySocketTCP* mySock;
|
||||
|
||||
/** client interface */
|
||||
ClientInterface* clientInterface;
|
||||
};
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "slsReceiverTCPIPInterface.h"
|
||||
#include "slsReceiverImplementation.h"
|
||||
#include "MySocketTCP.h"
|
||||
#include "ClientInterface.h"
|
||||
#include "gitInfoReceiver.h"
|
||||
#include "slsReceiverUsers.h"
|
||||
#include "slsReceiver.h"
|
||||
@ -28,6 +29,8 @@ slsReceiverTCPIPInterface::~slsReceiverTCPIPInterface() {
|
||||
delete mySock;
|
||||
mySock=NULL;
|
||||
}
|
||||
if (clientInterface)
|
||||
delete clientInterface;
|
||||
if(receiverBase)
|
||||
delete receiverBase;
|
||||
}
|
||||
@ -41,7 +44,8 @@ slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int pn):
|
||||
killTCPServerThread(0),
|
||||
tcpThreadCreated(false),
|
||||
portNumber(DEFAULT_PORTNO+2),
|
||||
mySock(0)
|
||||
mySock(0),
|
||||
clientInterface(0)
|
||||
{
|
||||
//***callback parameters***
|
||||
startAcquisitionCallBack = NULL;
|
||||
@ -56,6 +60,7 @@ slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int pn):
|
||||
portNumber = (pn > 0 ? pn : DEFAULT_PORTNO + 2);
|
||||
MySocketTCP* m = new MySocketTCP(portNumber);
|
||||
mySock = m;
|
||||
clientInterface = new ClientInterface(mySock);
|
||||
|
||||
//initialize variables
|
||||
strcpy(mySock->lastClientIP,"none");
|
||||
@ -564,6 +569,7 @@ int slsReceiverTCPIPInterface::set_port() {
|
||||
mySock->Disconnect();
|
||||
delete mySock;
|
||||
mySock = mySocket;
|
||||
clientInterface->SetSocket(mySock);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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