mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 23:30:03 +02:00
included the stop receiver function for the users
This commit is contained in:
parent
af89269c0c
commit
567501c6f7
@ -31,6 +31,7 @@ slsReceiverTCPIPInterface::~slsReceiverTCPIPInterface() {
|
|||||||
|
|
||||||
slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int argc, char *argv[], int &success):
|
slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int argc, char *argv[], int &success):
|
||||||
myDetectorType(GOTTHARD),
|
myDetectorType(GOTTHARD),
|
||||||
|
slsReceiverFunctions(NULL),
|
||||||
ret(OK),
|
ret(OK),
|
||||||
lockStatus(0),
|
lockStatus(0),
|
||||||
shortFrame(-1),
|
shortFrame(-1),
|
||||||
@ -168,7 +169,6 @@ slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int argc, char *argv[], int
|
|||||||
//Catch signal SIGINT to close files properly
|
//Catch signal SIGINT to close files properly
|
||||||
signal(SIGINT,staticCloseFile);
|
signal(SIGINT,staticCloseFile);
|
||||||
|
|
||||||
|
|
||||||
file_des=socket->getFileDes();
|
file_des=socket->getFileDes();
|
||||||
socketDescriptor=socket->getsocketDescriptor();
|
socketDescriptor=socket->getsocketDescriptor();
|
||||||
|
|
||||||
@ -178,6 +178,7 @@ slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int argc, char *argv[], int
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void slsReceiverTCPIPInterface::start(){
|
void slsReceiverTCPIPInterface::start(){
|
||||||
|
|
||||||
int v=slsReceiverDefs::OK;
|
int v=slsReceiverDefs::OK;
|
||||||
@ -203,9 +204,18 @@ void slsReceiverTCPIPInterface::start(){
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void slsReceiverTCPIPInterface::stop(){
|
||||||
|
//shut down udp socket
|
||||||
|
if(slsReceiverFunctions)
|
||||||
|
slsReceiverFunctions->shutDownUDPSocket();
|
||||||
|
//disconnect and delete socket
|
||||||
|
socket->Disconnect();
|
||||||
|
delete socket;
|
||||||
|
//close file and exit
|
||||||
|
closeFile(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/********************************************//**
|
/********************************************//**
|
||||||
* @file slsReceiverTCPIPInterface.h
|
* @file slsReceiverTCPIPInterface.h
|
||||||
* @short interface between receiver and client
|
* @short interface between receiver and client
|
||||||
***********************************************/
|
***********************************************/
|
||||||
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@short interface between receiver and client
|
*@short interface between receiver and client
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class slsReceiverTCPIPInterface : private virtual slsReceiverDefs {
|
class slsReceiverTCPIPInterface : private virtual slsReceiverDefs {
|
||||||
|
|
||||||
@ -27,13 +27,14 @@ public:
|
|||||||
* @param argv from command line
|
* @param argv from command line
|
||||||
* @param succecc socket creation was successfull
|
* @param succecc socket creation was successfull
|
||||||
*/
|
*/
|
||||||
slsReceiverTCPIPInterface(int argc, char *argv[], int &success);
|
slsReceiverTCPIPInterface(int argc, char *argv[], int &success);
|
||||||
|
|
||||||
|
/** starts listening on the TCP port for client comminication */
|
||||||
/** starts listening on the TCP port for client comminication */
|
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
|
/** stop listening on the TCP & UDP port for client comminication and exit receiver */
|
||||||
|
void stop();
|
||||||
|
|
||||||
/** Destructor */
|
/** Destructor */
|
||||||
virtual ~slsReceiverTCPIPInterface();
|
virtual ~slsReceiverTCPIPInterface();
|
||||||
|
|
||||||
@ -52,14 +53,14 @@ public:
|
|||||||
filename
|
filename
|
||||||
fileindex
|
fileindex
|
||||||
data size
|
data size
|
||||||
|
|
||||||
return value is
|
return value is
|
||||||
0 callback takes care of open,close,wrie file
|
0 callback takes care of open,close,wrie file
|
||||||
1 callback writes file, we have to open, close it
|
1 callback writes file, we have to open, close it
|
||||||
2 we open, close, write file, callback does not do anything
|
2 we open, close, write file, callback does not do anything
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg){slsReceiverFunctions->registerCallBackStartAcquisition(func,arg);};;
|
void registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg){slsReceiverFunctions->registerCallBackStartAcquisition(func,arg);};;
|
||||||
|
|
||||||
|
|
||||||
@ -67,11 +68,11 @@ public:
|
|||||||
callback argument is
|
callback argument is
|
||||||
toatal farmes caught
|
toatal farmes caught
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
void registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg){slsReceiverFunctions->registerCallBackAcquisitionFinished(func,arg);};
|
void registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg){slsReceiverFunctions->registerCallBackAcquisitionFinished(func,arg);};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,12 +82,12 @@ public:
|
|||||||
datasize in bytes
|
datasize in bytes
|
||||||
file descriptor
|
file descriptor
|
||||||
guidatapointer (NULL, no data required)
|
guidatapointer (NULL, no data required)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg){slsReceiverFunctions->registerCallBackRawDataReady(func,arg);};
|
void registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg){slsReceiverFunctions->registerCallBackRawDataReady(func,arg);};
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** assigns functions to the fnum enum */
|
/** assigns functions to the fnum enum */
|
||||||
int function_table();
|
int function_table();
|
||||||
|
|
||||||
@ -228,8 +229,8 @@ public:
|
|||||||
static int file_des;
|
static int file_des;
|
||||||
static int socketDescriptor;
|
static int socketDescriptor;
|
||||||
|
|
||||||
//private:
|
//private:
|
||||||
protected:
|
protected:
|
||||||
/** Socket */
|
/** Socket */
|
||||||
MySocketTCP* socket;
|
MySocketTCP* socket;
|
||||||
};
|
};
|
||||||
|
@ -105,7 +105,7 @@ void slsReceiverUDPFunctions::deleteMembers(){
|
|||||||
receiverdata[i] = NULL;
|
receiverdata[i] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(udpSocket) {delete udpSocket; udpSocket = NULL;}
|
shutDownUDPSocket();
|
||||||
if(eth) {delete [] eth; eth = NULL;}
|
if(eth) {delete [] eth; eth = NULL;}
|
||||||
if(latestData) {delete [] latestData; latestData = NULL;}
|
if(latestData) {delete [] latestData; latestData = NULL;}
|
||||||
if(guiFileName) {delete [] guiFileName; guiFileName = NULL;}
|
if(guiFileName) {delete [] guiFileName; guiFileName = NULL;}
|
||||||
@ -802,14 +802,11 @@ void slsReceiverUDPFunctions::copyFrameToGui(char* startbuf){
|
|||||||
|
|
||||||
int slsReceiverUDPFunctions::createUDPSocket(){
|
int slsReceiverUDPFunctions::createUDPSocket(){
|
||||||
|
|
||||||
if(udpSocket)
|
|
||||||
udpSocket->ShutDownSocket();
|
|
||||||
|
|
||||||
//if eth is mistaken with ip address
|
//if eth is mistaken with ip address
|
||||||
if (strchr(eth,'.')!=NULL)
|
if (strchr(eth,'.')!=NULL)
|
||||||
strcpy(eth,"");
|
strcpy(eth,"");
|
||||||
|
|
||||||
if(udpSocket){delete udpSocket; udpSocket = NULL;}
|
shutDownUDPSocket();
|
||||||
|
|
||||||
//if no eth, listen to all
|
//if no eth, listen to all
|
||||||
if(!strlen(eth)){
|
if(!strlen(eth)){
|
||||||
@ -838,6 +835,22 @@ int slsReceiverUDPFunctions::createUDPSocket(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int slsReceiverUDPFunctions::shutDownUDPSocket(){
|
||||||
|
if(udpSocket){
|
||||||
|
udpSocket->ShutDownSocket();
|
||||||
|
delete udpSocket;
|
||||||
|
udpSocket = NULL;
|
||||||
|
}
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int slsReceiverUDPFunctions::createListeningThreads(bool destroy){
|
int slsReceiverUDPFunctions::createListeningThreads(bool destroy){
|
||||||
void* status;
|
void* status;
|
||||||
|
|
||||||
@ -1224,8 +1237,7 @@ int slsReceiverUDPFunctions::startReceiver(char message[]){
|
|||||||
|
|
||||||
if(setupWriter() == FAIL){
|
if(setupWriter() == FAIL){
|
||||||
//stop udp socket
|
//stop udp socket
|
||||||
if(udpSocket)
|
shutDownUDPSocket();
|
||||||
udpSocket->ShutDownSocket();
|
|
||||||
|
|
||||||
sprintf(message,"Could not create file %s.\n",savefilename);
|
sprintf(message,"Could not create file %s.\n",savefilename);
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@ -1312,11 +1324,7 @@ void slsReceiverUDPFunctions::startReadout(){
|
|||||||
cout << "Status: Transmitting" << endl;
|
cout << "Status: Transmitting" << endl;
|
||||||
|
|
||||||
//kill udp socket to tell the listening thread to push last packet
|
//kill udp socket to tell the listening thread to push last packet
|
||||||
if(udpSocket){
|
shutDownUDPSocket();
|
||||||
udpSocket->ShutDownSocket();
|
|
||||||
delete udpSocket;
|
|
||||||
udpSocket = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,6 +266,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
void startReadout();
|
void startReadout();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* shuts down the udp socket
|
||||||
|
* \returns if success or fail
|
||||||
|
*/
|
||||||
|
int shutDownUDPSocket();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
@ -15,6 +15,10 @@ void slsReceiverUsers::start() {
|
|||||||
slsReceiverUsers::receiver->start();
|
slsReceiverUsers::receiver->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void slsReceiverUsers::stop() {
|
||||||
|
slsReceiverUsers::receiver->stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void slsReceiverUsers::closeFile(int p) {
|
void slsReceiverUsers::closeFile(int p) {
|
||||||
slsReceiverUsers::receiver->closeFile(p);
|
slsReceiverUsers::receiver->closeFile(p);
|
||||||
|
@ -40,6 +40,9 @@ public:
|
|||||||
/** starts listening on the TCP port for client comminication */
|
/** starts listening on the TCP port for client comminication */
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
|
/** stops listening to the TCP & UDP port and exit receiver program*/
|
||||||
|
void stop();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
get get Receiver Version
|
get get Receiver Version
|
||||||
\returns id
|
\returns id
|
||||||
|
Loading…
x
Reference in New Issue
Block a user