mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 03:10:02 +02:00
rxr: removed slsReceiverUsers, start() and stop()
This commit is contained in:
parent
f2c0ff7f98
commit
dc78e23449
@ -1,8 +1,7 @@
|
|||||||
set(SOURCES
|
set(SOURCES
|
||||||
src/slsReceiverImplementation.cpp
|
src/slsReceiverImplementation.cpp
|
||||||
src/slsReceiverTCPIPInterface.cpp
|
src/slsReceiverTCPIPInterface.cpp
|
||||||
src/slsReceiver.cpp
|
src/Receiver.cpp
|
||||||
src/slsReceiverUsers.cpp
|
|
||||||
src/File.cpp
|
src/File.cpp
|
||||||
src/BinaryFile.cpp
|
src/BinaryFile.cpp
|
||||||
src/ThreadObject.cpp
|
src/ThreadObject.cpp
|
||||||
@ -60,7 +59,7 @@ endif (SLS_USE_HDF5)
|
|||||||
|
|
||||||
#What is included in slsReceiverLib?
|
#What is included in slsReceiverLib?
|
||||||
set(PUBLICHEADERS
|
set(PUBLICHEADERS
|
||||||
include/slsReceiverUsers.h
|
include/Receiver.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,20 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
/********************************************//**
|
|
||||||
* @file slsReceiver.h
|
|
||||||
* @short creates the UDP and TCP class objects
|
|
||||||
***********************************************/
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "slsReceiverTCPIPInterface.h"
|
#include "slsReceiverTCPIPInterface.h"
|
||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
/**
|
class Receiver : private virtual slsDetectorDefs {
|
||||||
*@short creates the UDP and TCP class objects
|
|
||||||
*/
|
|
||||||
|
|
||||||
class slsReceiver : private virtual slsDetectorDefs {
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@ -25,7 +15,7 @@ class slsReceiver : private virtual slsDetectorDefs {
|
|||||||
* @param argc from command line
|
* @param argc from command line
|
||||||
* @param argv from command line
|
* @param argv from command line
|
||||||
*/
|
*/
|
||||||
slsReceiver(int argc, char *argv[]);
|
Receiver(int argc, char *argv[]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -34,18 +24,7 @@ class slsReceiver : private virtual slsDetectorDefs {
|
|||||||
* throws an exception in case of failure
|
* throws an exception in case of failure
|
||||||
* @param tcpip_port_no TCP/IP port number
|
* @param tcpip_port_no TCP/IP port number
|
||||||
*/
|
*/
|
||||||
slsReceiver(int tcpip_port_no = 1954);
|
Receiver(int tcpip_port_no = 1954);
|
||||||
|
|
||||||
/**
|
|
||||||
* starts listening on the TCP port for client comminication
|
|
||||||
\return 0 for success or 1 for FAIL in creating TCP server
|
|
||||||
*/
|
|
||||||
int start();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* stops listening to the TCP & UDP port and exit receiver program
|
|
||||||
*/
|
|
||||||
void stop();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get get Receiver Version
|
* get get Receiver Version
|
||||||
@ -70,16 +49,16 @@ class slsReceiver : private virtual slsDetectorDefs {
|
|||||||
/**
|
/**
|
||||||
* Call back for acquisition finished
|
* Call back for acquisition finished
|
||||||
* callback argument is
|
* callback argument is
|
||||||
* total frames caught
|
* @param total frames caught
|
||||||
*/
|
*/
|
||||||
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg);
|
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call back for raw data
|
* Call back for raw data
|
||||||
* args to raw data ready callback are
|
* args to raw data ready callback are
|
||||||
* sls_receiver_header frame metadata
|
* @param sls_receiver_header frame metadata
|
||||||
* dataPointer is the pointer to the data
|
* @param dataPointer is the pointer to the data
|
||||||
* dataSize in bytes is the size of the data in bytes.
|
* @param dataSize in bytes is the size of the data in bytes.
|
||||||
*/
|
*/
|
||||||
void registerCallBackRawDataReady(void (*func)(char* ,
|
void registerCallBackRawDataReady(void (*func)(char* ,
|
||||||
char*, uint32_t, void*),void *arg);
|
char*, uint32_t, void*),void *arg);
|
||||||
@ -87,9 +66,9 @@ class slsReceiver : private virtual slsDetectorDefs {
|
|||||||
/**
|
/**
|
||||||
* Call back for raw data (modified)
|
* Call back for raw data (modified)
|
||||||
* args to raw data ready callback are
|
* args to raw data ready callback are
|
||||||
* sls_receiver_header frame metadata
|
* @param sls_receiver_header frame metadata
|
||||||
* dataPointer is the pointer to the data
|
* @param dataPointer is the pointer to the data
|
||||||
* revDatasize is the reference of data size in bytes.
|
* @param revDatasize is the reference of data size in bytes.
|
||||||
* Can be modified to the new size to be written/streamed. (only smaller value).
|
* Can be modified to the new size to be written/streamed. (only smaller value).
|
||||||
*/
|
*/
|
||||||
void registerCallBackRawDataModifyReady(void (*func)(char* ,
|
void registerCallBackRawDataModifyReady(void (*func)(char* ,
|
@ -37,9 +37,8 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts listening on the TCP port for client comminication
|
* Starts listening on the TCP port for client comminication
|
||||||
\returns OK or FAIL
|
|
||||||
*/
|
*/
|
||||||
int start();
|
void start();
|
||||||
|
|
||||||
/** stop listening on the TCP & UDP port for client comminication */
|
/** stop listening on the TCP & UDP port for client comminication */
|
||||||
void stop();
|
void stop();
|
||||||
|
@ -1,92 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "slsReceiver.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
@short Class for implementing the SLS data receiver in the users application. Callbacks can be defined for processing and/or saving data
|
|
||||||
|
|
||||||
slsReceiverUsers is a class that can be instantiated in the users software to receive the data from the detectors. Callbacks can be defined for processing and/or saving data
|
|
||||||
***********************************************/
|
|
||||||
|
|
||||||
class slsReceiverUsers {
|
|
||||||
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
* reads config file, creates socket, assigns function table
|
|
||||||
* @param argc from command line
|
|
||||||
* @param argv from command line
|
|
||||||
* @param success socket creation was successfull
|
|
||||||
*/
|
|
||||||
slsReceiverUsers(int argc, char *argv[], int &success);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
* reads config file, creates socket, assigns function table
|
|
||||||
* @param tcpip_port_no TCP/IP port
|
|
||||||
* @throws
|
|
||||||
*/
|
|
||||||
slsReceiverUsers(int tcpip_port_no = 1954);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* starts listening on the TCP port for client comminication
|
|
||||||
\return 0 for success or 1 for FAIL in creating TCP server
|
|
||||||
*/
|
|
||||||
int start();
|
|
||||||
|
|
||||||
/** stops listening to the TCP & UDP port and exit receiver program*/
|
|
||||||
void stop();
|
|
||||||
|
|
||||||
/**
|
|
||||||
get get Receiver Version
|
|
||||||
\returns id
|
|
||||||
*/
|
|
||||||
int64_t getReceiverVersion();
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
@short register calbback for starting the acquisition
|
|
||||||
\param func callback to be called when starting the acquisition. Its arguments are filepath, filename, fileindex, datasize
|
|
||||||
\param arg argument
|
|
||||||
\return value is insignificant at the moment, we write depending on file write enable, users get data to write depending on call backs registered
|
|
||||||
*/
|
|
||||||
void registerCallBackStartAcquisition(int (*func)(std::string filepath, std::string filename, uint64_t fileindex, uint32_t datasize, void*),void *arg);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
@short register callback for end of acquisition
|
|
||||||
\param func end of acquisition callback. Argument nf is total frames caught
|
|
||||||
\param arg argument
|
|
||||||
\returns nothing
|
|
||||||
*/
|
|
||||||
void registerCallBackAcquisitionFinished(void (*func)(uint64_t nf, void*),void *arg);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
@short register callback to be called when data are available (to process and/or save the data).
|
|
||||||
\param func raw data ready callback. arguments are sls_receiver_header, dataPointer, dataSize
|
|
||||||
\param arg argument
|
|
||||||
\returns nothing
|
|
||||||
*/
|
|
||||||
void registerCallBackRawDataReady(void (*func)(char* header,
|
|
||||||
char* datapointer, uint32_t datasize, void*),void *arg);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
@short register callback to be called when data are available (to process and/or save the data).
|
|
||||||
\param func raw data ready callback. arguments are sls_receiver_header, dataPointer, revDatasize is the reference of data size in bytes. Can be modified to the new size to be written/streamed. (only smaller value).
|
|
||||||
\param arg argument
|
|
||||||
\returns nothing
|
|
||||||
*/
|
|
||||||
void registerCallBackRawDataModifyReady(void (*func)(char* header,
|
|
||||||
char* datapointer, uint32_t &revDatasize, void*),void *arg);
|
|
||||||
|
|
||||||
//receiver object
|
|
||||||
std::unique_ptr<slsReceiver> receiver;
|
|
||||||
};
|
|
@ -81,6 +81,6 @@ LATEX_HIDE_INDICES = YES
|
|||||||
|
|
||||||
PREDEFINED = __cplusplus
|
PREDEFINED = __cplusplus
|
||||||
|
|
||||||
INPUT = include/slsReceiverUsers.h
|
INPUT = include/Receiver.h
|
||||||
|
|
||||||
OUTPUT_DIRECTORY = slsReceiverUsersDocs
|
OUTPUT_DIRECTORY = slsReceiverUsersDocs
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
/********************************************//**
|
#include "Receiver.h"
|
||||||
* @file slsReceiver.cpp
|
#include "slsReceiverTCPIPInterface.h"
|
||||||
* @short creates the UDP and TCP class objects
|
#include "sls_detector_exceptions.h"
|
||||||
***********************************************/
|
#include "versionAPI.h"
|
||||||
|
#include "container_utils.h"
|
||||||
|
#include "logger.h"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@ -11,15 +13,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "container_utils.h" // For sls::make_unique<>
|
Receiver::Receiver(int argc, char *argv[]):
|
||||||
|
|
||||||
#include "logger.h"
|
|
||||||
#include "slsReceiver.h"
|
|
||||||
#include "slsReceiverTCPIPInterface.h"
|
|
||||||
#include "sls_detector_exceptions.h"
|
|
||||||
#include "versionAPI.h"
|
|
||||||
|
|
||||||
slsReceiver::slsReceiver(int argc, char *argv[]):
|
|
||||||
tcpipInterface (nullptr) {
|
tcpipInterface (nullptr) {
|
||||||
|
|
||||||
// options
|
// options
|
||||||
@ -81,47 +75,36 @@ slsReceiver::slsReceiver(int argc, char *argv[]):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
slsReceiver::slsReceiver(int tcpip_port_no)
|
Receiver::Receiver(int tcpip_port_no)
|
||||||
{
|
{
|
||||||
// might throw an exception
|
// might throw an exception
|
||||||
tcpipInterface = sls::make_unique<slsReceiverTCPIPInterface>(tcpip_port_no);
|
tcpipInterface = sls::make_unique<slsReceiverTCPIPInterface>(tcpip_port_no);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t Receiver::getReceiverVersion(){
|
||||||
int slsReceiver::start() {
|
|
||||||
return tcpipInterface->start();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void slsReceiver::stop() {
|
|
||||||
tcpipInterface->stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int64_t slsReceiver::getReceiverVersion(){
|
|
||||||
return tcpipInterface->getReceiverVersion();
|
return tcpipInterface->getReceiverVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void slsReceiver::registerCallBackStartAcquisition(int (*func)(
|
void Receiver::registerCallBackStartAcquisition(int (*func)(
|
||||||
std::string, std::string, uint64_t, uint32_t, void*),void *arg){
|
std::string, std::string, uint64_t, uint32_t, void*),void *arg){
|
||||||
tcpipInterface->registerCallBackStartAcquisition(func,arg);
|
tcpipInterface->registerCallBackStartAcquisition(func,arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void slsReceiver::registerCallBackAcquisitionFinished(
|
void Receiver::registerCallBackAcquisitionFinished(
|
||||||
void (*func)(uint64_t, void*),void *arg){
|
void (*func)(uint64_t, void*),void *arg){
|
||||||
tcpipInterface->registerCallBackAcquisitionFinished(func,arg);
|
tcpipInterface->registerCallBackAcquisitionFinished(func,arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void slsReceiver::registerCallBackRawDataReady(void (*func)(char*,
|
void Receiver::registerCallBackRawDataReady(void (*func)(char*,
|
||||||
char*, uint32_t, void*),void *arg){
|
char*, uint32_t, void*),void *arg){
|
||||||
tcpipInterface->registerCallBackRawDataReady(func,arg);
|
tcpipInterface->registerCallBackRawDataReady(func,arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void slsReceiver::registerCallBackRawDataModifyReady(void (*func)(char*,
|
void Receiver::registerCallBackRawDataModifyReady(void (*func)(char*,
|
||||||
char*, uint32_t &, void*),void *arg){
|
char*, uint32_t &, void*),void *arg){
|
||||||
tcpipInterface->registerCallBackRawDataModifyReady(func,arg);
|
tcpipInterface->registerCallBackRawDataModifyReady(func,arg);
|
||||||
}
|
}
|
@ -2,8 +2,9 @@
|
|||||||
The port number is passed as an argument */
|
The port number is passed as an argument */
|
||||||
|
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "slsReceiverUsers.h"
|
#include "Receiver.h"
|
||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
|
#include "container_utils.h"
|
||||||
|
|
||||||
#include <csignal> //SIGINT
|
#include <csignal> //SIGINT
|
||||||
#include <cstdlib> //system
|
#include <cstdlib> //system
|
||||||
@ -13,7 +14,7 @@
|
|||||||
#include <sys/wait.h> //wait
|
#include <sys/wait.h> //wait
|
||||||
#include <syscall.h>
|
#include <syscall.h>
|
||||||
#include <unistd.h> //usleep
|
#include <unistd.h> //usleep
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
bool keeprunning;
|
bool keeprunning;
|
||||||
|
|
||||||
@ -88,16 +89,14 @@ int main(int argc, char *argv[]) {
|
|||||||
FILE_LOG(logERROR) << "Could not set handler function for SIGPIPE";
|
FILE_LOG(logERROR) << "Could not set handler function for SIGPIPE";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<Receiver> receiver = nullptr;
|
||||||
int ret = slsDetectorDefs::OK;
|
try {
|
||||||
slsReceiverUsers *receiver = new slsReceiverUsers(argc, argv, ret);
|
receiver = sls::make_unique<Receiver>(argc, argv);
|
||||||
if(ret==slsDetectorDefs::FAIL){
|
} catch (...) {
|
||||||
delete receiver;
|
|
||||||
FILE_LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]";
|
FILE_LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]";
|
||||||
exit(EXIT_FAILURE);
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//register callbacks
|
//register callbacks
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -137,21 +136,10 @@ int main(int argc, char *argv[]) {
|
|||||||
*/
|
*/
|
||||||
//receiver->registerCallBackRawDataReady(rawDataReadyCallBack,NULL);
|
//receiver->registerCallBackRawDataReady(rawDataReadyCallBack,NULL);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//start tcp server thread
|
|
||||||
if (receiver->start() == slsDetectorDefs::FAIL){
|
|
||||||
delete receiver;
|
|
||||||
FILE_LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]";
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
FILE_LOG(logINFO) << "Ready ... ";
|
FILE_LOG(logINFO) << "Ready ... ";
|
||||||
FILE_LOG(logINFO) << "[ Press \'Ctrl+c\' to exit ]";
|
FILE_LOG(logINFO) << "[ Press \'Ctrl+c\' to exit ]";
|
||||||
while(keeprunning)
|
while(keeprunning)
|
||||||
pause();
|
pause();
|
||||||
|
|
||||||
delete receiver;
|
|
||||||
FILE_LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]";
|
FILE_LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]";
|
||||||
FILE_LOG(logINFO) << "Exiting Receiver";
|
FILE_LOG(logINFO) << "Exiting Receiver";
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
\file mainReceiver.cpp
|
\file mainReceiver.cpp
|
||||||
|
|
||||||
This file is an example of how to implement the slsReceiverUsers class
|
This file is an example of how to implement the Receiver class
|
||||||
You can compile it linking it to the slsReceiver library
|
You can compile it linking it to the slsReceiver library
|
||||||
|
|
||||||
g++ mainReceiver.cpp -L lib -lSlsReceiver -L/usr/lib64/ -L lib2 -lzmq -pthread -lrt -lm -lstdc++
|
g++ mainReceiver.cpp -L lib -lSlsReceiver -L/usr/lib64/ -L lib2 -lzmq -pthread -lrt -lm -lstdc++
|
||||||
@ -17,14 +17,12 @@ It is linked in manual/manual-api from slsReceiverSoftware/include ]
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
#include "slsReceiverUsers.h"
|
#include "Receiver.h"
|
||||||
|
|
||||||
#include <csignal> //SIGINT
|
#include <csignal> //SIGINT
|
||||||
#include <cstdlib> //system
|
#include <cstdlib> //system
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
//#include "utilities.h"
|
|
||||||
//#include "logger.h"
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sys/types.h> //wait
|
#include <sys/types.h> //wait
|
||||||
@ -155,7 +153,7 @@ void GetData(char* metadata, char* datapointer, uint32_t &revDatasize, void* p){
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Example of main program using the slsReceiverUsers class
|
* Example of main program using the Receiver class
|
||||||
*
|
*
|
||||||
* - Defines in file for:
|
* - Defines in file for:
|
||||||
* - Default Number of receivers is 1
|
* - Default Number of receivers is 1
|
||||||
@ -215,17 +213,7 @@ int main(int argc, char *argv[]) {
|
|||||||
else if (pid == 0) {
|
else if (pid == 0) {
|
||||||
cprintf(BLUE,"Child process %d [ Tid: %ld ]\n", i, (long)syscall(SYS_gettid));
|
cprintf(BLUE,"Child process %d [ Tid: %ld ]\n", i, (long)syscall(SYS_gettid));
|
||||||
|
|
||||||
char temp[10];
|
Receiver *receiver = new Receiver(startTCPPort + i);
|
||||||
sprintf(temp,"%d",startTCPPort + i);
|
|
||||||
char* args[] = {(char*)"ignored", (char*)"--rx_tcpport", temp};
|
|
||||||
int ret = slsDetectorDefs::OK;
|
|
||||||
/** - create slsReceiverUsers object with appropriate arguments */
|
|
||||||
slsReceiverUsers *receiver = new slsReceiverUsers(3, args, ret);
|
|
||||||
if(ret==slsDetectorDefs::FAIL){
|
|
||||||
delete receiver;
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** - register callbacks. remember to set file write enable to 0 (using the client)
|
/** - register callbacks. remember to set file write enable to 0 (using the client)
|
||||||
if we should not write files and you will write data using the callbacks */
|
if we should not write files and you will write data using the callbacks */
|
||||||
@ -245,19 +233,10 @@ int main(int argc, char *argv[]) {
|
|||||||
else if (withCallback == 2) receiver->registerCallBackRawDataModifyReady(GetData,nullptr);
|
else if (withCallback == 2) receiver->registerCallBackRawDataModifyReady(GetData,nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** - start tcp server thread */
|
|
||||||
if (receiver->start() == slsDetectorDefs::FAIL){
|
|
||||||
delete receiver;
|
|
||||||
cprintf(BLUE,"Exiting Child Process [ Tid: %ld ]\n", (long)syscall(SYS_gettid));
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** - as long as keeprunning is true (changes with Ctrl+C) */
|
/** - as long as keeprunning is true (changes with Ctrl+C) */
|
||||||
while(keeprunning)
|
while(keeprunning)
|
||||||
pause();
|
pause();
|
||||||
/** - interrupt caught, delete slsReceiverUsers object and exit */
|
/** - interrupt caught, delete Receiver object and exit */
|
||||||
delete receiver;
|
delete receiver;
|
||||||
cprintf(BLUE,"Exiting Child Process [ Tid: %ld ]\n", (long)syscall(SYS_gettid));
|
cprintf(BLUE,"Exiting Child Process [ Tid: %ld ]\n", (long)syscall(SYS_gettid));
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
@ -8,9 +8,7 @@
|
|||||||
#include "slsReceiverTCPIPInterface.h"
|
#include "slsReceiverTCPIPInterface.h"
|
||||||
#include "FixedCapacityContainer.h"
|
#include "FixedCapacityContainer.h"
|
||||||
#include "ServerSocket.h"
|
#include "ServerSocket.h"
|
||||||
#include "slsReceiver.h"
|
|
||||||
#include "slsReceiverImplementation.h"
|
#include "slsReceiverImplementation.h"
|
||||||
#include "slsReceiverUsers.h"
|
|
||||||
#include "sls_detector_exceptions.h"
|
#include "sls_detector_exceptions.h"
|
||||||
#include "string_utils.h"
|
#include "string_utils.h"
|
||||||
#include "versionAPI.h"
|
#include "versionAPI.h"
|
||||||
@ -35,19 +33,18 @@ slsReceiverTCPIPInterface::~slsReceiverTCPIPInterface() { stop(); }
|
|||||||
slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int pn)
|
slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int pn)
|
||||||
: myDetectorType(GOTTHARD), portNumber(pn > 0 ? pn : DEFAULT_PORTNO + 2) {
|
: myDetectorType(GOTTHARD), portNumber(pn > 0 ? pn : DEFAULT_PORTNO + 2) {
|
||||||
function_table();
|
function_table();
|
||||||
|
start();
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::start() {
|
void slsReceiverTCPIPInterface::start() {
|
||||||
FILE_LOG(logDEBUG) << "Creating TCP Server Thread";
|
FILE_LOG(logDEBUG) << "Creating TCP Server Thread";
|
||||||
killTCPServerThread = 0;
|
killTCPServerThread = 0;
|
||||||
if (pthread_create(&TCPServer_thread, nullptr, startTCPServerThread,
|
if (pthread_create(&TCPServer_thread, nullptr, startTCPServerThread,
|
||||||
(void *)this)) {
|
(void *)this)) {
|
||||||
FILE_LOG(logERROR) << "Could not create TCP Server thread";
|
throw RuntimeError("Could not create TCP Server thread");
|
||||||
return FAIL;
|
|
||||||
}
|
}
|
||||||
tcpThreadCreated = true;
|
tcpThreadCreated = true;
|
||||||
FILE_LOG(logDEBUG) << "TCP Server thread created successfully.";
|
FILE_LOG(logDEBUG) << "TCP Server thread created successfully.";
|
||||||
return OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void slsReceiverTCPIPInterface::stop() {
|
void slsReceiverTCPIPInterface::stop() {
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
#include "container_utils.h" // For sls::make_unique<>
|
|
||||||
|
|
||||||
#include "slsReceiverUsers.h"
|
|
||||||
|
|
||||||
slsReceiverUsers::slsReceiverUsers(int argc, char *argv[], int &success) {
|
|
||||||
// catch the exception here to limit it to within the library (for current version)
|
|
||||||
try {
|
|
||||||
receiver = sls::make_unique<slsReceiver>(argc, argv);
|
|
||||||
success = slsDetectorDefs::OK;
|
|
||||||
} catch (...) {
|
|
||||||
success = slsDetectorDefs::FAIL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
slsReceiverUsers::slsReceiverUsers(int tcpip_port_no) {
|
|
||||||
receiver = sls::make_unique<slsReceiver>(tcpip_port_no);
|
|
||||||
}
|
|
||||||
|
|
||||||
int slsReceiverUsers::start() {
|
|
||||||
return receiver->start();
|
|
||||||
}
|
|
||||||
|
|
||||||
void slsReceiverUsers::stop() {
|
|
||||||
receiver->stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t slsReceiverUsers::getReceiverVersion(){
|
|
||||||
return receiver->getReceiverVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
void slsReceiverUsers::registerCallBackStartAcquisition(int (*func)(std::string, std::string, uint64_t, uint32_t, void*),void *arg){
|
|
||||||
receiver->registerCallBackStartAcquisition(func,arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void slsReceiverUsers::registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg){
|
|
||||||
receiver->registerCallBackAcquisitionFinished(func,arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void slsReceiverUsers::registerCallBackRawDataReady(void (*func)(char* header,
|
|
||||||
char* datapointer, uint32_t datasize, void*), void *arg){
|
|
||||||
receiver->registerCallBackRawDataReady(func,arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void slsReceiverUsers::registerCallBackRawDataModifyReady(void (*func)(char* header,
|
|
||||||
char* datapointer, uint32_t& revDatasize, void*), void *arg){
|
|
||||||
receiver->registerCallBackRawDataModifyReady(func,arg);
|
|
||||||
}
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user