mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-20 02:40:03 +02:00
esrf changes: Listener, DataProcessor, DataStreamer, Fifo, ZmqSocket constructors return an exception when it fails
This commit is contained in:
parent
fdd19bc316
commit
d3a0319863
@ -176,7 +176,7 @@ public:
|
|||||||
retval.append("Could not configure mac\n");
|
retval.append("Could not configure mac\n");
|
||||||
|
|
||||||
if(slsErrorMask&COULDNOT_SET_NETWORK_PARAMETER)
|
if(slsErrorMask&COULDNOT_SET_NETWORK_PARAMETER)
|
||||||
retval.append("Could not set network parameter. Should be valid and in proper format\n");
|
retval.append("Could not set network parameter.\n");
|
||||||
|
|
||||||
if(slsErrorMask&COULDNOT_SET_ROI)
|
if(slsErrorMask&COULDNOT_SET_ROI)
|
||||||
retval.append("Could not set the exact region of interest. Verify ROI set by detector.\n");
|
retval.append("Could not set the exact region of interest. Verify ROI set by detector.\n");
|
||||||
|
@ -6030,9 +6030,10 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy){
|
|||||||
uint32_t portnum = 0;
|
uint32_t portnum = 0;
|
||||||
sscanf(detectors[i/numSocketsPerDetector]->getClientStreamingPort().c_str(),"%d",&portnum);
|
sscanf(detectors[i/numSocketsPerDetector]->getClientStreamingPort().c_str(),"%d",&portnum);
|
||||||
portnum += (i%numSocketsPerDetector);
|
portnum += (i%numSocketsPerDetector);
|
||||||
cout<<"ip to be set to :"<<detectors[i/numSocketsPerDetector]->getClientStreamingIP().c_str()<<endl;
|
//cout<<"ip to be set to :"<<detectors[i/numSocketsPerDetector]->getClientStreamingIP().c_str()<<endl;
|
||||||
|
try {
|
||||||
zmqSocket[i] = new ZmqSocket(detectors[i/numSocketsPerDetector]->getClientStreamingIP().c_str(), portnum);
|
zmqSocket[i] = new ZmqSocket(detectors[i/numSocketsPerDetector]->getClientStreamingIP().c_str(), portnum);
|
||||||
if (zmqSocket[i]->IsError()) {
|
} catch(...) {
|
||||||
cprintf(RED, "Error: Could not create Zmq socket on port %d\n", portnum);
|
cprintf(RED, "Error: Could not create Zmq socket on port %d\n", portnum);
|
||||||
createReceivingDataSockets(true);
|
createReceivingDataSockets(true);
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
@ -6420,6 +6420,7 @@ string slsDetector::setReceiver(string receiverIP){
|
|||||||
setDetectorId();
|
setDetectorId();
|
||||||
setDetectorHostname();
|
setDetectorHostname();
|
||||||
setUDPConnection();
|
setUDPConnection();
|
||||||
|
//setReceiverUDPSocketBufferSize(atoi(getReceiverUDPSocketBufferSize().c_str()));
|
||||||
|
|
||||||
setFilePath(fileIO::getFilePath());
|
setFilePath(fileIO::getFilePath());
|
||||||
setFileName(fileIO::getFileName());
|
setFileName(fileIO::getFileName());
|
||||||
|
@ -28,7 +28,7 @@ int receiverInterface::sendString(int fnum, char retval[], char arg[]){
|
|||||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||||
if (ret==slsDetectorDefs::FAIL){
|
if (ret==slsDetectorDefs::FAIL){
|
||||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||||
std::cout<< "Receiver returned error: " << mess << std::endl;
|
cprintf(RED, "Receiver returned error: %s", mess);
|
||||||
}
|
}
|
||||||
dataSocket->ReceiveDataOnly(retval,MAX_STR_LENGTH);
|
dataSocket->ReceiveDataOnly(retval,MAX_STR_LENGTH);
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ int receiverInterface::sendUDPDetails(int fnum, char retval[], char arg[3][MAX_S
|
|||||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||||
if (ret==slsDetectorDefs::FAIL){
|
if (ret==slsDetectorDefs::FAIL){
|
||||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||||
std::cout<< "Receiver returned error: " << mess << std::endl;
|
cprintf(RED, "Receiver returned error: %s", mess);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dataSocket->ReceiveDataOnly(retval,MAX_STR_LENGTH);
|
dataSocket->ReceiveDataOnly(retval,MAX_STR_LENGTH);
|
||||||
@ -65,7 +65,7 @@ int receiverInterface::sendInt(int fnum, int &retval, int arg){
|
|||||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||||
if (ret==slsDetectorDefs::FAIL){
|
if (ret==slsDetectorDefs::FAIL){
|
||||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||||
std::cout<< "Receiver returned error: " << mess << std::endl;
|
cprintf(RED, "Receiver returned error: %s", mess);
|
||||||
}
|
}
|
||||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ int receiverInterface::getInt(int fnum, int &retval){
|
|||||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||||
if (ret==slsDetectorDefs::FAIL){
|
if (ret==slsDetectorDefs::FAIL){
|
||||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||||
std::cout<< "Receiver returned error: " << mess << std::endl;
|
cprintf(RED, "Receiver returned error: %s", mess);
|
||||||
}
|
}
|
||||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ int receiverInterface::sendInt(int fnum, int64_t &retval, int64_t arg){
|
|||||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||||
if (ret==slsDetectorDefs::FAIL){
|
if (ret==slsDetectorDefs::FAIL){
|
||||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||||
std::cout<< "Receiver returned error: " << mess << std::endl;
|
cprintf(RED, "Receiver returned error: %s", mess);
|
||||||
}
|
}
|
||||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ int receiverInterface::sendIntArray(int fnum, int64_t &retval, int64_t arg[2], c
|
|||||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||||
if (ret==slsDetectorDefs::FAIL){
|
if (ret==slsDetectorDefs::FAIL){
|
||||||
dataSocket->ReceiveDataOnly(mess,sizeof(messs));
|
dataSocket->ReceiveDataOnly(mess,sizeof(messs));
|
||||||
std::cout<< "Receiver returned error: " << mess << std::endl;
|
cprintf(RED, "Receiver returned error: %s", mess);
|
||||||
}
|
}
|
||||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ int receiverInterface::sendIntArray(int fnum, int &retval, int arg[2]){
|
|||||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||||
if (ret==slsDetectorDefs::FAIL){
|
if (ret==slsDetectorDefs::FAIL){
|
||||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||||
std::cout<< "Receiver returned error: " << mess << std::endl;
|
cprintf(RED, "Receiver returned error: %s", mess);
|
||||||
}
|
}
|
||||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||||
|
|
||||||
@ -175,7 +175,7 @@ int receiverInterface::executeFunction(int fnum,char mess[]){
|
|||||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||||
if (ret==slsDetectorDefs::FAIL){
|
if (ret==slsDetectorDefs::FAIL){
|
||||||
dataSocket->ReceiveDataOnly(mess,MAX_STR_LENGTH);
|
dataSocket->ReceiveDataOnly(mess,MAX_STR_LENGTH);
|
||||||
std::cout<< "Receiver returned error: " << mess << std::endl;
|
cprintf(RED, "Receiver returned error: %s", mess);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -24,7 +24,6 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* Calls Base Class CreateThread(), sets ErrorMask if error and increments NumberofDataProcessors
|
* Calls Base Class CreateThread(), sets ErrorMask if error and increments NumberofDataProcessors
|
||||||
* @param ret OK or FAIL if thread creation succeeded or failed
|
|
||||||
* @param ind self index
|
* @param ind self index
|
||||||
* @param f address of Fifo pointer
|
* @param f address of Fifo pointer
|
||||||
* @param ftype pointer to file format type
|
* @param ftype pointer to file format type
|
||||||
@ -37,7 +36,7 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
* @param dataReadycb pointer to data ready call back function
|
* @param dataReadycb pointer to data ready call back function
|
||||||
* @param pDataReadycb pointer to arguments of data ready call back function. To write/stream a smaller size of processed data, change this value (only smaller value is allowed).
|
* @param pDataReadycb pointer to arguments of data ready call back function. To write/stream a smaller size of processed data, change this value (only smaller value is allowed).
|
||||||
*/
|
*/
|
||||||
DataProcessor(int& ret, int ind, Fifo*& f, fileFormat* ftype, bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr,
|
DataProcessor(int ind, Fifo*& f, fileFormat* ftype, bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr,
|
||||||
uint32_t* freq, uint32_t* timer,
|
uint32_t* freq, uint32_t* timer,
|
||||||
void (*dataReadycb)(uint64_t, uint32_t, uint32_t, uint64_t,
|
void (*dataReadycb)(uint64_t, uint32_t, uint32_t, uint64_t,
|
||||||
uint64_t, uint16_t, uint16_t, uint16_t, uint16_t,
|
uint64_t, uint16_t, uint16_t, uint16_t, uint16_t,
|
||||||
|
@ -20,7 +20,6 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* Calls Base Class CreateThread(), sets ErrorMask if error and increments NumberofDataStreamers
|
* Calls Base Class CreateThread(), sets ErrorMask if error and increments NumberofDataStreamers
|
||||||
* @param ret OK or FAIL if thread creation succeeded or failed
|
|
||||||
* @param ind self index
|
* @param ind self index
|
||||||
* @param f address of Fifo pointer
|
* @param f address of Fifo pointer
|
||||||
* @param dr pointer to dynamic range
|
* @param dr pointer to dynamic range
|
||||||
@ -29,7 +28,7 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
* @param fd flipped data enable for x and y dimensions
|
* @param fd flipped data enable for x and y dimensions
|
||||||
* @param ajh additional json header
|
* @param ajh additional json header
|
||||||
*/
|
*/
|
||||||
DataStreamer(int& ret, int ind, Fifo*& f, uint32_t* dr, int* sEnable, uint64_t* fi, int* fd, char* ajh);
|
DataStreamer(int ind, Fifo*& f, uint32_t* dr, int* sEnable, uint64_t* fi, int* fd, char* ajh);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
@ -87,12 +86,12 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates Zmq Sockets
|
* Creates Zmq Sockets
|
||||||
|
* (throws an exception if it couldnt create zmq sockets)
|
||||||
* @param nunits pointer to number of theads/ units per detector
|
* @param nunits pointer to number of theads/ units per detector
|
||||||
* @param port streaming port start index
|
* @param port streaming port start index
|
||||||
* @param srcip streaming source ip
|
* @param srcip streaming source ip
|
||||||
* @return OK or FAIL
|
|
||||||
*/
|
*/
|
||||||
int CreateZmqSockets(int* nunits, uint32_t port, const char* srcip);
|
void CreateZmqSockets(int* nunits, uint32_t port, const char* srcip);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shuts down and deletes Zmq Sockets
|
* Shuts down and deletes Zmq Sockets
|
||||||
|
@ -23,9 +23,8 @@ class Fifo : private virtual slsReceiverDefs {
|
|||||||
* @param ind self index
|
* @param ind self index
|
||||||
* @param fifoItemSize size of each fifo item
|
* @param fifoItemSize size of each fifo item
|
||||||
* @param depth fifo depth
|
* @param depth fifo depth
|
||||||
* @param success true if successful, else false
|
|
||||||
*/
|
*/
|
||||||
Fifo(int ind, uint32_t fifoItemSize, uint32_t depth, bool &success);
|
Fifo(int ind, uint32_t fifoItemSize, uint32_t depth);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
|
@ -21,7 +21,6 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* Calls Base Class CreateThread(), sets ErrorMask if error and increments NumberofListerners
|
* Calls Base Class CreateThread(), sets ErrorMask if error and increments NumberofListerners
|
||||||
* @param ret OK or FAIL if thread creation succeeded or failed
|
|
||||||
* @param ind self index
|
* @param ind self index
|
||||||
* @param dtype detector type
|
* @param dtype detector type
|
||||||
* @param f address of Fifo pointer
|
* @param f address of Fifo pointer
|
||||||
@ -34,7 +33,7 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
* @param us pointer to udp socket buffer size
|
* @param us pointer to udp socket buffer size
|
||||||
* @param as pointer to actual udp socket buffer size
|
* @param as pointer to actual udp socket buffer size
|
||||||
*/
|
*/
|
||||||
Listener(int& ret, int ind, detectorType dtype, Fifo*& f, runStatus* s,
|
Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s,
|
||||||
uint32_t* portno, char* e, int* act, uint64_t* nf, uint32_t* dr,
|
uint32_t* portno, char* e, int* act, uint64_t* nf, uint32_t* dr,
|
||||||
uint32_t* us, uint32_t* as);
|
uint32_t* us, uint32_t* as);
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ public:
|
|||||||
struct addrinfo *result;
|
struct addrinfo *result;
|
||||||
if ((ConvertHostnameToInternetAddress(hostname_or_ip, &result)) ||
|
if ((ConvertHostnameToInternetAddress(hostname_or_ip, &result)) ||
|
||||||
(ConvertInternetAddresstoIpString(result, ip, MAX_STR_LENGTH)))
|
(ConvertInternetAddresstoIpString(result, ip, MAX_STR_LENGTH)))
|
||||||
return;
|
throw std::exception();
|
||||||
|
|
||||||
// construct address
|
// construct address
|
||||||
sprintf (serverAddress, "tcp://%s:%d", ip, portno);
|
sprintf (serverAddress, "tcp://%s:%d", ip, portno);
|
||||||
@ -69,29 +69,32 @@ public:
|
|||||||
// create context
|
// create context
|
||||||
contextDescriptor = zmq_ctx_new();
|
contextDescriptor = zmq_ctx_new();
|
||||||
if (contextDescriptor == NULL)
|
if (contextDescriptor == NULL)
|
||||||
return;
|
throw std::exception();
|
||||||
|
|
||||||
// create publisher
|
// create publisher
|
||||||
socketDescriptor = zmq_socket (contextDescriptor, ZMQ_SUB);
|
socketDescriptor = zmq_socket (contextDescriptor, ZMQ_SUB);
|
||||||
if (socketDescriptor == NULL) {
|
if (socketDescriptor == NULL) {
|
||||||
PrintError ();
|
PrintError ();
|
||||||
Close ();
|
Close ();
|
||||||
|
throw std::exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Socket Options provided above
|
//Socket Options provided above
|
||||||
// an empty string implies receiving any messages
|
// an empty string implies receiving any messages
|
||||||
if ( zmq_setsockopt(socketDescriptor, ZMQ_SUBSCRIBE, "", 0)) {
|
if ( zmq_setsockopt(socketDescriptor, ZMQ_SUBSCRIBE, "", 0)) {
|
||||||
PrintError ();
|
PrintError ();
|
||||||
Close();
|
Close();
|
||||||
|
throw std::exception();
|
||||||
}
|
}
|
||||||
//ZMQ_LINGER default is already -1 means no messages discarded. use this options if optimizing required
|
//ZMQ_LINGER default is already -1 means no messages discarded. use this options if optimizing required
|
||||||
//ZMQ_SNDHWM default is 0 means no limit. use this to optimize if optimizing required
|
//ZMQ_SNDHWM default is 0 means no limit. use this to optimize if optimizing required
|
||||||
// eg. int value = -1;
|
// eg. int value = -1;
|
||||||
int value = 0;
|
int value = 0;
|
||||||
if (zmq_setsockopt(socketDescriptor, ZMQ_LINGER, &value,sizeof(value))) {
|
if (zmq_setsockopt(socketDescriptor, ZMQ_LINGER, &value,sizeof(value))) {
|
||||||
PrintError ();
|
PrintError ();
|
||||||
Close();
|
Close();
|
||||||
}
|
throw std::exception();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,13 +114,13 @@ public:
|
|||||||
// create context
|
// create context
|
||||||
contextDescriptor = zmq_ctx_new();
|
contextDescriptor = zmq_ctx_new();
|
||||||
if (contextDescriptor == NULL)
|
if (contextDescriptor == NULL)
|
||||||
return;
|
throw std::exception();
|
||||||
// create publisher
|
// create publisher
|
||||||
socketDescriptor = zmq_socket (contextDescriptor, ZMQ_PUB);
|
socketDescriptor = zmq_socket (contextDescriptor, ZMQ_PUB);
|
||||||
if (socketDescriptor == NULL) {
|
if (socketDescriptor == NULL) {
|
||||||
PrintError ();
|
PrintError ();
|
||||||
Close ();
|
Close ();
|
||||||
return;
|
throw std::exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Socket Options provided above
|
//Socket Options provided above
|
||||||
@ -131,7 +134,7 @@ public:
|
|||||||
if (zmq_bind (socketDescriptor, serverAddress) < 0) {
|
if (zmq_bind (socketDescriptor, serverAddress) < 0) {
|
||||||
PrintError ();
|
PrintError ();
|
||||||
Close ();
|
Close ();
|
||||||
return;
|
throw std::exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
//sleep for a few milliseconds to allow a slow-joiner
|
//sleep for a few milliseconds to allow a slow-joiner
|
||||||
@ -146,11 +149,6 @@ public:
|
|||||||
Close();
|
Close();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns error status
|
|
||||||
* @returns true if error else false
|
|
||||||
*/
|
|
||||||
bool IsError() { if (socketDescriptor == NULL) return true; return false; };
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns Server Address
|
* Returns Server Address
|
||||||
|
@ -231,11 +231,11 @@ enum communicationProtocol{
|
|||||||
|
|
||||||
// confirm if sufficient
|
// confirm if sufficient
|
||||||
if (getsockopt(socketDescriptor, SOL_SOCKET, SO_RCVBUF, &ret_size, &optlen) == -1) {
|
if (getsockopt(socketDescriptor, SOL_SOCKET, SO_RCVBUF, &ret_size, &optlen) == -1) {
|
||||||
FILE_LOG(logWARNING) << "[Port " << port_number << "] Could not get Socket Receive Buffer Size";
|
FILE_LOG(logWARNING) << "[Port " << port_number << "] Could not get rx socket receive buffer size";
|
||||||
} else if (ret_size >= real_size) {
|
} else if (ret_size >= real_size) {
|
||||||
actual_udp_socket_buffer_size = ret_size;
|
actual_udp_socket_buffer_size = ret_size;
|
||||||
#ifdef VEBOSE
|
#ifdef VEBOSE
|
||||||
FILE_LOG(logINFO) << "[Port " << port_number << "] UDP Socket Buffer Size is sufficient (" << ret_size << ")";
|
FILE_LOG(logINFO) << "[Port " << port_number << "] UDP rx socket buffer size is sufficient (" << ret_size << ")";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,16 +243,16 @@ enum communicationProtocol{
|
|||||||
else {
|
else {
|
||||||
// set buffer size (could not set)
|
// set buffer size (could not set)
|
||||||
if (setsockopt(socketDescriptor, SOL_SOCKET, SO_RCVBUF, &desired_size, optlen) == -1) {
|
if (setsockopt(socketDescriptor, SOL_SOCKET, SO_RCVBUF, &desired_size, optlen) == -1) {
|
||||||
FILE_LOG(logWARNING) << "[Port " << port_number << "] Could not set Socket Receive Buffer Size to "
|
FILE_LOG(logWARNING) << "[Port " << port_number << "] Could not set rx socket buffer size to "
|
||||||
<< desired_size << ". No Root Privileges?";
|
<< desired_size << ". (No Root Privileges?)";
|
||||||
}
|
}
|
||||||
// confirm size
|
// confirm size
|
||||||
else if (getsockopt(socketDescriptor, SOL_SOCKET, SO_RCVBUF, &ret_size, &optlen) == -1) {
|
else if (getsockopt(socketDescriptor, SOL_SOCKET, SO_RCVBUF, &ret_size, &optlen) == -1) {
|
||||||
FILE_LOG(logWARNING) << "[Port " << port_number << "] Could not get Socket Receive Buffer Size";
|
FILE_LOG(logWARNING) << "[Port " << port_number << "] Could not get rx socket buffer size";
|
||||||
}
|
}
|
||||||
else if (ret_size >= real_size) {
|
else if (ret_size >= real_size) {
|
||||||
actual_udp_socket_buffer_size = ret_size;
|
actual_udp_socket_buffer_size = ret_size;
|
||||||
FILE_LOG(logINFO) << "[Port " << port_number << "] UDP Socket Buffer Size modified to " << ret_size;
|
FILE_LOG(logINFO) << "[Port " << port_number << "] UDP rx socket buffer size modified to " << ret_size;
|
||||||
}
|
}
|
||||||
// buffer size too large
|
// buffer size too large
|
||||||
else {
|
else {
|
||||||
@ -262,13 +262,13 @@ enum communicationProtocol{
|
|||||||
getsockopt(socketDescriptor, SOL_SOCKET, SO_RCVBUF, &ret_size, &optlen);
|
getsockopt(socketDescriptor, SOL_SOCKET, SO_RCVBUF, &ret_size, &optlen);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
FILE_LOG(logWARNING) << "[Port " << port_number << "] "
|
FILE_LOG(logWARNING) << "[Port " << port_number << "] "
|
||||||
"Could not force Socket Receive Buffer Size to "
|
"Could not force rx socket buffer size to "
|
||||||
<< desired_size << ". Real size is " << ret_size <<
|
<< desired_size << ".\n Real size: " << ret_size <<
|
||||||
". (No Root Privileges?)\n"
|
". (No Root Privileges?)\n"
|
||||||
"Set rx_udpsocksize from the client to <= " <<
|
" To remove this warning: set rx_udpsocksize from client to <= " <<
|
||||||
(ret_size/2) << " (Real size:" << ret_size << ") to remove this warning.\n";
|
(ret_size/2) << " (Real size:" << ret_size << ").";
|
||||||
} else {
|
} else {
|
||||||
FILE_LOG(logINFO) << "[Port " << port_number << "] UDP socket buffer size modified to " << ret_size;
|
FILE_LOG(logINFO) << "[Port " << port_number << "] UDP rx socket buffer size modified to " << ret_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ using namespace std;
|
|||||||
const string DataProcessor::TypeName = "DataProcessor";
|
const string DataProcessor::TypeName = "DataProcessor";
|
||||||
|
|
||||||
|
|
||||||
DataProcessor::DataProcessor(int& ret, int ind, Fifo*& f, fileFormat* ftype, bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr,
|
DataProcessor::DataProcessor(int ind, Fifo*& f, fileFormat* ftype, bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr,
|
||||||
uint32_t* freq, uint32_t* timer,
|
uint32_t* freq, uint32_t* timer,
|
||||||
void (*dataReadycb)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t,
|
void (*dataReadycb)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t,
|
||||||
uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
||||||
@ -61,9 +61,8 @@ DataProcessor::DataProcessor(int& ret, int ind, Fifo*& f, fileFormat* ftype, boo
|
|||||||
rawDataModifyReadyCallBack(dataModifyReadycb),
|
rawDataModifyReadyCallBack(dataModifyReadycb),
|
||||||
pRawDataReady(pDataReadycb)
|
pRawDataReady(pDataReadycb)
|
||||||
{
|
{
|
||||||
ret = FAIL;
|
if(ThreadObject::CreateThread() == FAIL)
|
||||||
if(ThreadObject::CreateThread() == OK)
|
throw std::exception();
|
||||||
ret = OK;
|
|
||||||
|
|
||||||
FILE_LOG(logDEBUG) << "DataProcessor " << ind << " created";
|
FILE_LOG(logDEBUG) << "DataProcessor " << ind << " created";
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ using namespace std;
|
|||||||
const string DataStreamer::TypeName = "DataStreamer";
|
const string DataStreamer::TypeName = "DataStreamer";
|
||||||
|
|
||||||
|
|
||||||
DataStreamer::DataStreamer(int& ret, int ind, Fifo*& f, uint32_t* dr, int* sEnable, uint64_t* fi, int* fd, char* ajh) :
|
DataStreamer::DataStreamer(int ind, Fifo*& f, uint32_t* dr, int* sEnable, uint64_t* fi, int* fd, char* ajh) :
|
||||||
ThreadObject(ind),
|
ThreadObject(ind),
|
||||||
runningFlag(0),
|
runningFlag(0),
|
||||||
generalData(0),
|
generalData(0),
|
||||||
@ -34,13 +34,12 @@ DataStreamer::DataStreamer(int& ret, int ind, Fifo*& f, uint32_t* dr, int* sEnab
|
|||||||
additionJsonHeader(ajh),
|
additionJsonHeader(ajh),
|
||||||
silentMode(false)
|
silentMode(false)
|
||||||
{
|
{
|
||||||
ret = FAIL;
|
if(ThreadObject::CreateThread() == FAIL)
|
||||||
if(ThreadObject::CreateThread() == OK)
|
throw std::exception();
|
||||||
ret = OK;
|
|
||||||
|
|
||||||
FILE_LOG(logDEBUG) << "DataStreamer " << ind << " created";
|
FILE_LOG(logDEBUG) << "DataStreamer " << ind << " created";
|
||||||
|
|
||||||
strcpy(fileNametoStream, "");
|
memset(fileNametoStream, 0, MAX_STR_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -129,16 +128,16 @@ int DataStreamer::SetThreadPriority(int priority) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int DataStreamer::CreateZmqSockets(int* nunits, uint32_t port, const char* srcip) {
|
void DataStreamer::CreateZmqSockets(int* nunits, uint32_t port, const char* srcip) {
|
||||||
uint32_t portnum = port + index;
|
uint32_t portnum = port + index;
|
||||||
|
|
||||||
zmqSocket = new ZmqSocket(portnum, (strlen(srcip)?srcip:NULL));
|
try {
|
||||||
if (zmqSocket->IsError()) {
|
zmqSocket = new ZmqSocket(portnum, (strlen(srcip)?srcip:NULL));
|
||||||
|
} catch (...) {
|
||||||
cprintf(RED, "Error: Could not create Zmq socket on port %d for Streamer %d\n", portnum, index);
|
cprintf(RED, "Error: Could not create Zmq socket on port %d for Streamer %d\n", portnum, index);
|
||||||
return FAIL;
|
throw;
|
||||||
}
|
}
|
||||||
FILE_LOG(logINFO) << index << " Streamer: Zmq Server started at " << zmqSocket->GetZmqServerAddress();
|
FILE_LOG(logINFO) << index << " Streamer: Zmq Server started at " << zmqSocket->GetZmqServerAddress();
|
||||||
return OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
Fifo::Fifo(int ind, uint32_t fifoItemSize, uint32_t depth, bool &success):
|
Fifo::Fifo(int ind, uint32_t fifoItemSize, uint32_t depth):
|
||||||
index(ind),
|
index(ind),
|
||||||
memory(0),
|
memory(0),
|
||||||
fifoBound(0),
|
fifoBound(0),
|
||||||
@ -23,9 +23,8 @@ Fifo::Fifo(int ind, uint32_t fifoItemSize, uint32_t depth, bool &success):
|
|||||||
status_fifoBound(0),
|
status_fifoBound(0),
|
||||||
status_fifoFree(depth){
|
status_fifoFree(depth){
|
||||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
success = true;
|
|
||||||
if(CreateFifos(fifoItemSize) == FAIL)
|
if(CreateFifos(fifoItemSize) == FAIL)
|
||||||
success = false;
|
throw std::exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ using namespace std;
|
|||||||
const string Listener::TypeName = "Listener";
|
const string Listener::TypeName = "Listener";
|
||||||
|
|
||||||
|
|
||||||
Listener::Listener(int& ret, int ind, detectorType dtype, Fifo*& f, runStatus* s,
|
Listener::Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s,
|
||||||
uint32_t* portno, char* e, int* act, uint64_t* nf, uint32_t* dr,
|
uint32_t* portno, char* e, int* act, uint64_t* nf, uint32_t* dr,
|
||||||
uint32_t* us, uint32_t* as) :
|
uint32_t* us, uint32_t* as) :
|
||||||
ThreadObject(ind),
|
ThreadObject(ind),
|
||||||
@ -49,9 +49,8 @@ Listener::Listener(int& ret, int ind, detectorType dtype, Fifo*& f, runStatus* s
|
|||||||
udpSocketBufferSize(us),
|
udpSocketBufferSize(us),
|
||||||
actualUDPSocketBufferSize(as)
|
actualUDPSocketBufferSize(as)
|
||||||
{
|
{
|
||||||
ret = FAIL;
|
if(ThreadObject::CreateThread() == FAIL)
|
||||||
if(ThreadObject::CreateThread() == OK)
|
throw std::exception();
|
||||||
ret = OK;
|
|
||||||
|
|
||||||
FILE_LOG(logDEBUG) << "Listener " << ind << " created";
|
FILE_LOG(logDEBUG) << "Listener " << ind << " created";
|
||||||
}
|
}
|
||||||
@ -235,6 +234,7 @@ void Listener::SetSilentMode(bool mode) {
|
|||||||
|
|
||||||
|
|
||||||
int Listener::CreateDummySocketForUDPSocketBufferSize(uint32_t s) {
|
int Listener::CreateDummySocketForUDPSocketBufferSize(uint32_t s) {
|
||||||
|
FILE_LOG(logINFO) << "Testing UDP Socket Buffer size with test port " << *udpPortNumber;
|
||||||
uint32_t temp = *udpSocketBufferSize;
|
uint32_t temp = *udpSocketBufferSize;
|
||||||
*udpSocketBufferSize = s;
|
*udpSocketBufferSize = s;
|
||||||
|
|
||||||
@ -263,11 +263,11 @@ int Listener::CreateDummySocketForUDPSocketBufferSize(uint32_t s) {
|
|||||||
FILE_LOG(logERROR) << "Could not create a test UDP socket on port " << *udpPortNumber << " error: " << iret;
|
FILE_LOG(logERROR) << "Could not create a test UDP socket on port " << *udpPortNumber << " error: " << iret;
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// doubled due to kernel bookkeeping (could also be less due to permissions)
|
// doubled due to kernel bookkeeping (could also be less due to permissions)
|
||||||
*actualUDPSocketBufferSize = udpSocket->getActualUDPSocketBufferSize();
|
*actualUDPSocketBufferSize = udpSocket->getActualUDPSocketBufferSize();
|
||||||
if (*actualUDPSocketBufferSize != (s*2))
|
if (*actualUDPSocketBufferSize != (s*2)) {
|
||||||
*udpSocketBufferSize = temp;
|
*udpSocketBufferSize = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// shutdown socket
|
// shutdown socket
|
||||||
|
@ -217,32 +217,23 @@ int UDPStandardImplementation::setDataStreamEnable(const bool enable) {
|
|||||||
dataStreamer.clear();
|
dataStreamer.clear();
|
||||||
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
for ( int i = 0; i < numThreads; ++i ) {
|
for ( int i = 0; i < numThreads; ++i ) {
|
||||||
|
try {
|
||||||
int ret = FAIL;
|
DataStreamer* s = new DataStreamer(i, fifo[i], &dynamicRange,
|
||||||
DataStreamer* s = new DataStreamer(ret, i, fifo[i], &dynamicRange, &shortFrameEnable, &fileIndex, flippedData, additionalJsonHeader);
|
&shortFrameEnable, &fileIndex, flippedData, additionalJsonHeader);
|
||||||
if (ret == FAIL)
|
dataStreamer.push_back(s);
|
||||||
cprintf(RED,"Error: Could not create data callback threads\n");
|
dataStreamer[i]->SetGeneralData(generalData);
|
||||||
else {
|
dataStreamer[i]->CreateZmqSockets(&numThreads, streamingPort, streamingSrcIP);
|
||||||
dataStreamer.push_back(s);
|
}
|
||||||
dataStreamer[i]->SetGeneralData(generalData);
|
catch(...) {
|
||||||
if (dataStreamer[i]->CreateZmqSockets(&numThreads, streamingPort, streamingSrcIP) == FAIL) {
|
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
||||||
cprintf(RED,"Error: Could not create zmq sockets\n");
|
delete(*it);
|
||||||
ret = FAIL;
|
dataStreamer.clear();
|
||||||
}
|
dataStreamEnable = false;
|
||||||
}
|
return FAIL;
|
||||||
|
}
|
||||||
// error in creating threads or zmq sockets
|
}
|
||||||
if (ret == FAIL) {
|
SetThreadPriorities();
|
||||||
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
|
||||||
delete(*it);
|
|
||||||
dataStreamer.clear();
|
|
||||||
dataStreamEnable = false;
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SetThreadPriorities();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FILE_LOG(logINFO) << "Data Send to Gui: " << dataStreamEnable;
|
FILE_LOG(logINFO) << "Data Send to Gui: " << dataStreamEnable;
|
||||||
@ -375,31 +366,28 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) {
|
|||||||
//create threads
|
//create threads
|
||||||
for ( int i = 0; i < numThreads; ++i ) {
|
for ( int i = 0; i < numThreads; ++i ) {
|
||||||
|
|
||||||
int ret = FAIL;
|
try {
|
||||||
Listener* l = new Listener(ret, i, myDetectorType, fifo[i], &status,
|
Listener* l = new Listener(i, myDetectorType, fifo[i], &status,
|
||||||
&udpPortNum[i], eth, &activated, &numberOfFrames, &dynamicRange,
|
&udpPortNum[i], eth, &activated, &numberOfFrames, &dynamicRange,
|
||||||
&udpSocketBufferSize, &actualUDPSocketBufferSize);
|
&udpSocketBufferSize, &actualUDPSocketBufferSize);
|
||||||
DataProcessor* p = NULL;
|
listener.push_back(l);
|
||||||
if (ret == OK)
|
|
||||||
p = new DataProcessor(ret, i, fifo[i], &fileFormatType,
|
DataProcessor* p = new DataProcessor(i, fifo[i], &fileFormatType,
|
||||||
fileWriteEnable, &dataStreamEnable, &gapPixelsEnable,
|
fileWriteEnable, &dataStreamEnable, &gapPixelsEnable,
|
||||||
&dynamicRange, &frameToGuiFrequency, &frameToGuiTimerinMS,
|
&dynamicRange, &frameToGuiFrequency, &frameToGuiTimerinMS,
|
||||||
rawDataReadyCallBack, rawDataModifyReadyCallBack, pRawDataReady);
|
rawDataReadyCallBack, rawDataModifyReadyCallBack, pRawDataReady);
|
||||||
|
dataProcessor.push_back(p);
|
||||||
// error in creating threads
|
}
|
||||||
if (ret == FAIL) {
|
catch (...) {
|
||||||
FILE_LOG(logERROR) << "Could not create listener/dataprocessor threads (index:" << i << ")";
|
FILE_LOG(logERROR) << "Could not create listener/dataprocessor threads (index:" << i << ")";
|
||||||
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||||
delete(*it);
|
delete(*it);
|
||||||
listener.clear();
|
listener.clear();
|
||||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||||
delete(*it);
|
delete(*it);
|
||||||
dataProcessor.clear();
|
dataProcessor.clear();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
listener.push_back(l);
|
|
||||||
dataProcessor.push_back(p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//set up writer and callbacks
|
//set up writer and callbacks
|
||||||
@ -410,8 +398,8 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) {
|
|||||||
|
|
||||||
SetThreadPriorities();
|
SetThreadPriorities();
|
||||||
|
|
||||||
// check udp socket buffer size
|
// check udp socket buffer size
|
||||||
setUDPSocketBufferSize(udpSocketBufferSize);
|
setUDPSocketBufferSize(udpSocketBufferSize);
|
||||||
|
|
||||||
FILE_LOG(logDEBUG) << " Detector type set to " << getDetectorType(d);
|
FILE_LOG(logDEBUG) << " Detector type set to " << getDetectorType(d);
|
||||||
return OK;
|
return OK;
|
||||||
@ -673,11 +661,11 @@ void UDPStandardImplementation::SetLocalNetworkParameters() {
|
|||||||
if (proc_file.good()) {
|
if (proc_file.good()) {
|
||||||
proc_file << MAX_SOCKET_INPUT_PACKET_QUEUE << endl;
|
proc_file << MAX_SOCKET_INPUT_PACKET_QUEUE << endl;
|
||||||
cprintf(GREEN, "Max length of input packet queue "
|
cprintf(GREEN, "Max length of input packet queue "
|
||||||
"(/proc/sys/net/core/netdev_max_backlog) modified to %d\n",
|
"[/proc/sys/net/core/netdev_max_backlog] modified to %d\n",
|
||||||
MAX_SOCKET_INPUT_PACKET_QUEUE);
|
MAX_SOCKET_INPUT_PACKET_QUEUE);
|
||||||
} else {
|
} else {
|
||||||
const char *msg = "Could not change max length of"
|
const char *msg = "Could not change max length of"
|
||||||
"input packet queue (net.core.netdev_max_backlog). No Root Privileges?";
|
"input packet queue [net.core.netdev_max_backlog]. (No Root Privileges?)";
|
||||||
FILE_LOG(logWARNING) << msg;
|
FILE_LOG(logWARNING) << msg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -689,7 +677,7 @@ void UDPStandardImplementation::SetThreadPriorities() {
|
|||||||
|
|
||||||
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it){
|
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it){
|
||||||
if ((*it)->SetThreadPriority(LISTENER_PRIORITY) == FAIL) {
|
if ((*it)->SetThreadPriority(LISTENER_PRIORITY) == FAIL) {
|
||||||
FILE_LOG(logWARNING) << "Could not prioritize listener threads. No Root Privileges?";
|
FILE_LOG(logWARNING) << "Could not prioritize listener threads. (No Root Privileges?)";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -711,20 +699,18 @@ int UDPStandardImplementation::SetupFifoStructure() {
|
|||||||
for ( int i = 0; i < numThreads; i++ ) {
|
for ( int i = 0; i < numThreads; i++ ) {
|
||||||
|
|
||||||
//create fifo structure
|
//create fifo structure
|
||||||
bool success = true;
|
try {
|
||||||
Fifo* f = new Fifo (i,
|
Fifo* f = new Fifo (i,
|
||||||
(generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize),
|
(generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize),
|
||||||
fifoDepth, success);
|
fifoDepth);
|
||||||
//error
|
fifo.push_back(f);
|
||||||
if (!success) {
|
} catch (...) {
|
||||||
cprintf(RED,"Error: Could not allocate memory for fifo structure of index %d\n", i);
|
cprintf(RED,"Error: Could not allocate memory for fifo structure of index %d\n", i);
|
||||||
for (vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
|
for (vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
|
||||||
delete(*it);
|
delete(*it);
|
||||||
fifo.clear();
|
fifo.clear();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
fifo.push_back(f);
|
|
||||||
|
|
||||||
//set the listener & dataprocessor threads to point to the right fifo
|
//set the listener & dataprocessor threads to point to the right fifo
|
||||||
if(listener.size())listener[i]->SetFifo(fifo[i]);
|
if(listener.size())listener[i]->SetFifo(fifo[i]);
|
||||||
if(dataProcessor.size())dataProcessor[i]->SetFifo(fifo[i]);
|
if(dataProcessor.size())dataProcessor[i]->SetFifo(fifo[i]);
|
||||||
|
@ -2649,7 +2649,7 @@ int slsReceiverTCPIPInterface::set_udp_socket_buffer_size() {
|
|||||||
}
|
}
|
||||||
//get
|
//get
|
||||||
retval=receiverBase->getUDPSocketBufferSize();
|
retval=receiverBase->getUDPSocketBufferSize();
|
||||||
if(index >= 0 && retval != index) {
|
if(index >= 0 && ((retval != index) || (receiverBase->getActualUDPSocketBufferSize() != (index*2)))) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
strcpy(mess, "Could not set UDP Socket buffer size (No CAP_NET_ADMIN privileges?)\n");
|
strcpy(mess, "Could not set UDP Socket buffer size (No CAP_NET_ADMIN privileges?)\n");
|
||||||
FILE_LOG(logERROR) << mess;
|
FILE_LOG(logERROR) << mess;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user