Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer

This commit is contained in:
2019-05-14 18:38:42 +02:00
30 changed files with 91 additions and 444 deletions

View File

@ -17,7 +17,6 @@ set(PUBLICHEADERS
include/ansi.h
include/sls_detector_defs.h
include/sls_detector_funcs.h
include/error_defs.h
include/versionAPI.h
include/sls_detector_exceptions.h
include/file_utils.h

View File

@ -2,7 +2,6 @@
#include "sls_detector_defs.h"
#include "MySocketTCP.h"
#include "ClientSocket.h"

View File

@ -1,342 +0,0 @@
/*
* error_defs.h
*
* Created on: Jan 18, 2013
* Author: l_maliakal_d
*/
#ifndef ERROR_DEFS_H_
#define ERROR_DEFS_H_
#include "ansi.h"
#include "sls_detector_defs.h"
#include <stdio.h>
#include <string>
#include <cstring>
#include <iostream>
//
/** Error flags */
/*Assumption: Only upto 63 detectors */
// multi errors
// 0xFFF0000000000000ULL
#define MULTI_DETECTORS_NOT_ADDED 0x8000000000000000ULL
#define MULTI_HAVE_DIFFERENT_VALUES 0x4000000000000000ULL
#define MULTI_CONFIG_FILE_ERROR 0x2000000000000000ULL
#define MULTI_POS_EXCEEDS_LIST 0x1000000000000000ULL
#define MUST_BE_MULTI_CMD 0x0800000000000000ULL
#define MULTI_OTHER_ERROR 0x0400000000000000ULL
// sls errors
#define CRITICAL_ERROR_MASK 0xFFFFFFF
// 0xFFFFFFF000000000ULL
#define CANNOT_CONNECT_TO_DETECTOR 0x4000000000000000ULL
#define CANNOT_CONNECT_TO_RECEIVER 0x2000000000000000ULL
#define COULDNOT_SET_CONTROL_PORT 0x1000000000000000ULL
#define COULDNOT_SET_STOP_PORT 0x0800000000000000ULL
#define COULDNOT_SET_DATA_PORT 0x0400000000000000ULL
#define FILE_PATH_DOES_NOT_EXIST 0x0200000000000000ULL
#define COULDNOT_CREATE_UDP_SOCKET 0x0100000000000000ULL
#define COULDNOT_CREATE_FILE 0x0080000000000000ULL
#define RECEIVER_DET_HOSTNAME_NOT_SET 0x0040000000000000ULL
#define RECEIVER_DET_HOSTTYPE_NOT_SET 0x0020000000000000ULL
#define DETECTOR_TEN_GIGA 0x0010000000000000ULL
#define DETECTOR_ACTIVATE 0x0008000000000000ULL
#define COULD_NOT_CONFIGURE_MAC 0x0004000000000000ULL
#define COULDNOT_START_RECEIVER 0x0002000000000000ULL // default error like starting threads
#define COULDNOT_STOP_RECEIVER 0x0001000000000000ULL
#define RECEIVER_DET_POSID_NOT_SET 0x0000800000000000ULL
#define RECEIVER_MULTI_DET_SIZE_NOT_SET 0x0000400000000000ULL
#define PREPARE_ACQUISITION 0x0000200000000000ULL
#define REGISER_WRITE_READ 0x0000100000000000ULL
#define VERSION_COMPATIBILITY 0x0000080000000000ULL
// 0xFFFFFF0000000000ULL
// 0x000000FFFFFFFFFFULL
#define COULDNOT_SET_NETWORK_PARAMETER 0x0000000000000001ULL
#define COULDNOT_SET_ROI 0x0000000000000002ULL
#define RECEIVER_STREAMING_FREQUENCY 0x0000000000000004ULL
#define SETTINGS_NOT_SET 0x0000000000000008ULL
#define SETTINGS_FILE_NOT_OPEN 0x0000000000000010ULL
#define DETECTOR_TIMER_VALUE_NOT_SET 0x0000000000000020ULL
#define RECEIVER_ACQ_PERIOD_NOT_SET 0x0000000000000040ULL
#define RECEIVER_FRAME_NUM_NOT_SET 0x0000000000000080ULL
#define RECEIVER_DYNAMIC_RANGE 0x0000000000000100ULL
#define RECEIVER_TEN_GIGA 0x0000000000000200ULL
#define ALLTIMBITS_NOT_SET 0x0000000000000400ULL
#define COULD_NOT_SET_SPEED_PARAMETERS 0x0000000000000800ULL
#define COULD_NOT_SET_READOUT_FLAGS 0x0000000000001000ULL
#define COULD_NOT_SET_FIFO_DEPTH 0x0000000000002000ULL
#define COULD_NOT_SET_COUNTER_BIT 0x0000000000004000ULL
#define COULD_NOT_PULSE 0x0000000000008000ULL
#define COULD_NOT_SET_RATE_CORRECTION 0x0000000000010000ULL
#define DETECTOR_NETWORK_PARAMETER 0x0000000000020000ULL
#define RATE_CORRECTION_NOT_32or16BIT 0x0000000000040000ULL
#define RATE_CORRECTION_NO_TAU_PROVIDED 0x0000000000080000ULL
#define PROGRAMMING_ERROR 0x0000000000100000ULL
#define RECEIVER_ACTIVATE 0x0000000000200000ULL
#define DATA_STREAMING 0x0000000000400000ULL
#define RESET_ERROR 0x0000000000800000ULL
#define POWER_CHIP 0x0000000001000000ULL
#define RECEIVER_STREAMING_TIMER 0x0000000002000000ULL
#define RECEIVER_ACQ_TIME_NOT_SET 0x0000000004000000ULL
#define RECEIVER_FLIPPED_DATA_NOT_SET 0x0000000008000000ULL
#define THRESHOLD_NOT_SET 0x0000000010000000ULL
#define RECEIVER_FILE_FORMAT 0x0000000020000000ULL
#define RECEIVER_PARAMETER_NOT_SET 0x0000000040000000ULL
#define RECEIVER_TIMER_NOT_SET 0x0000000080000000ULL
#define RECEIVER_ENABLE_GAPPIXELS_NOT_SET 0x0000000100000000ULL
#define RESTREAM_STOP_FROM_RECEIVER 0x0000000200000000ULL
#define TEMPERATURE_CONTROL 0x0000000400000000ULL
#define AUTO_COMP_DISABLE 0x0000000800000000ULL
#define CONFIG_FILE 0x0000001000000000ULL
#define STORAGE_CELL_START 0x0000002000000000ULL
#define OTHER_ERROR_CODE 0x0000004000000000ULL
// 0x000000FFFFFFFFFFULL
/** @short class returning all error messages for error mask */
class errorDefs {
public:
/** Constructor */
errorDefs():errorMask(0){
strcpy(notAddedList,"");
};
/** Gets the error message
* param errorMask error mask
/returns error message from error mask
*/
static std::string getErrorMessage(int64_t slsErrorMask){
std::string retval = "";
if(slsErrorMask&CANNOT_CONNECT_TO_DETECTOR)
retval.append("Cannot connect to Detector\n");
if(slsErrorMask&CANNOT_CONNECT_TO_RECEIVER)
retval.append("Cannot connect to Receiver\n");
if(slsErrorMask&COULDNOT_SET_CONTROL_PORT)
retval.append("Could not set control port\n");
if(slsErrorMask&COULDNOT_SET_STOP_PORT)
retval.append("Could not set stop port\n");
if(slsErrorMask&COULDNOT_SET_DATA_PORT)
retval.append("Could not set receiver port\n");
if(slsErrorMask&FILE_PATH_DOES_NOT_EXIST)
retval.append("Path to Output Directory does not exist\n");
if(slsErrorMask&COULDNOT_CREATE_UDP_SOCKET)
retval.append("Could not create UDP socket to start receiver\n");
if(slsErrorMask&COULDNOT_CREATE_FILE)
retval.append("Could not create file to start receiver.\nCheck permissions of output directory or the overwrite flag\n");
if(slsErrorMask&RECEIVER_DET_HOSTNAME_NOT_SET)
retval.append("Could not send the detector hostname to the receiver.\n");
if(slsErrorMask&RECEIVER_DET_HOSTTYPE_NOT_SET)
retval.append("Could not send the detector type to the receiver.\n");
if(slsErrorMask&DETECTOR_TEN_GIGA)
retval.append("Could not enable/disable 10GbE in the detector.\n");
if(slsErrorMask&DETECTOR_ACTIVATE)
retval.append("Could not activate/deactivate detector\n");
if(slsErrorMask&RECEIVER_DET_POSID_NOT_SET)
retval.append("Could not set detector position id\n");
if(slsErrorMask&RECEIVER_MULTI_DET_SIZE_NOT_SET)
retval.append("Could not set multi detector size\n");
if(slsErrorMask&PREPARE_ACQUISITION)
retval.append("Could not prepare acquisition in detector\n");
if(slsErrorMask&REGISER_WRITE_READ)
retval.append("Could not read/write register in detector\n");
if(slsErrorMask&VERSION_COMPATIBILITY)
retval.append("Incompatible versions with detector or receiver. Please check log for more details.\n");
if(slsErrorMask&COULD_NOT_CONFIGURE_MAC)
retval.append("Could not configure mac\n");
if(slsErrorMask&COULDNOT_SET_NETWORK_PARAMETER)
retval.append("Could not set network parameter.\n");
if(slsErrorMask&COULDNOT_SET_ROI)
retval.append("Could not set the exact region of interest. Verify ROI set by detector.\n");
if(slsErrorMask&RECEIVER_STREAMING_FREQUENCY)
retval.append("Could not set receiver read frequency.\n");
if(slsErrorMask&SETTINGS_NOT_SET)
retval.append("Could not set settings.\n");
if(slsErrorMask&SETTINGS_FILE_NOT_OPEN)
retval.append("Could not open settings file. Verify if it exists.\n");
if(slsErrorMask&COULDNOT_START_RECEIVER)
retval.append("Could not start receiver.\n");
if(slsErrorMask&COULDNOT_STOP_RECEIVER)
retval.append("Could not stop receiver.\n");
if(slsErrorMask&DETECTOR_TIMER_VALUE_NOT_SET)
retval.append("Could not set one of timer values in detector.\n");
if(slsErrorMask&RECEIVER_ACQ_PERIOD_NOT_SET)
retval.append("Could not set acquisition period in receiver.\n");
if(slsErrorMask&RECEIVER_FRAME_NUM_NOT_SET)
retval.append("Could not set frame number in receiver.\n");
if(slsErrorMask&RECEIVER_DYNAMIC_RANGE)
retval.append("Could not set dynamic range in receiver.\n");
if(slsErrorMask&RECEIVER_TEN_GIGA)
retval.append("Could not enable/disable 10GbE in the receiver.\n");
if(slsErrorMask&ALLTIMBITS_NOT_SET)
retval.append("Could not set all trimbits to value.\n");
if(slsErrorMask&COULD_NOT_SET_SPEED_PARAMETERS)
retval.append("Could not set the speed parameter value\n");
if(slsErrorMask&COULD_NOT_SET_READOUT_FLAGS)
retval.append("Could not set the readout flag\n");
if(slsErrorMask&COULD_NOT_SET_FIFO_DEPTH)
retval.append("Could not set receiver fifo depth\n");
if(slsErrorMask&COULD_NOT_SET_COUNTER_BIT)
retval.append("Could not set/reset counter bit\n");
if(slsErrorMask&COULD_NOT_PULSE)
retval.append("Could not pulse pixel or chip\n");
if(slsErrorMask&COULD_NOT_SET_RATE_CORRECTION)
retval.append("Could not set rate correction\n");
if(slsErrorMask&DETECTOR_NETWORK_PARAMETER)
retval.append("Could not set/get detector network parameter\n");
if(slsErrorMask&RATE_CORRECTION_NOT_32or16BIT)
retval.append("Rate correction Deactivated, must be in 32 or 16 bit mode\n");
if(slsErrorMask&RATE_CORRECTION_NO_TAU_PROVIDED)
retval.append("Rate correction Deactivated. No default tau provided in file\n");
if(slsErrorMask&PROGRAMMING_ERROR)
retval.append("Could not program FPGA\n");
if(slsErrorMask&RECEIVER_ACTIVATE)
retval.append("Could not activate/deactivate receiver\n");
if(slsErrorMask&DATA_STREAMING)
retval.append("Could not enable/disable Data Streaming\n");
if(slsErrorMask&RESET_ERROR)
retval.append("Could not reset the FPGA\n");
if(slsErrorMask&POWER_CHIP)
retval.append("Could not power on/off/get the chip\n");
if(slsErrorMask&RECEIVER_STREAMING_TIMER)
retval.append("Could not set receiver read timer\n");
if(slsErrorMask&RECEIVER_FLIPPED_DATA_NOT_SET)
retval.append("Could not set receiver flipped data/bottom\n");
if(slsErrorMask&THRESHOLD_NOT_SET)
retval.append("Could not set threshold\n");
if(slsErrorMask&RECEIVER_FILE_FORMAT)
retval.append("Could not set receiver file format\n");
if(slsErrorMask&RECEIVER_TIMER_NOT_SET)
retval.append("Could not set timer in receiver.\n");
if(slsErrorMask&RECEIVER_PARAMETER_NOT_SET)
retval.append("Could not set a paramater in receiver.\n");
if(slsErrorMask&RECEIVER_ENABLE_GAPPIXELS_NOT_SET)
retval.append("Could not enable/disable gap pixels in receiver.\n");
if(slsErrorMask&RESTREAM_STOP_FROM_RECEIVER)
retval.append("Could not restream stop from receiver.\n");
if(slsErrorMask&TEMPERATURE_CONTROL)
retval.append("Could not set/get threshold temperature, temp control or temp event.\n");
if(slsErrorMask&AUTO_COMP_DISABLE)
retval.append("Could not set/get auto comparator disable\n");
if(slsErrorMask&CONFIG_FILE)
retval.append("Could not load/write config file\n");
if(slsErrorMask&OTHER_ERROR_CODE)
retval.append("Some error occured.\n");
//------------------------------------------------------ length of message
return retval;
}
/** Sets multi error mask
@param multi error mask to be set to
/returns multi error mask
*/
int64_t setErrorMask(int64_t i){errorMask=i;return getErrorMask();};
/**returns multi error mask */
int64_t getErrorMask(){return errorMask;};
/** Clears error mask
/returns error mask
*/
int64_t clearErrorMask(){errorMask=0;return errorMask;};
/** Gets the not added detector list
/returns list
*/
char* getNotAddedList(){return notAddedList;};
/** Append the detector to not added detector list
* @param name append to the list
/returns list
*/
void appendNotAddedList(const char* name){strcat(notAddedList,name);strcat(notAddedList,"+");};
/** Clears not added detector list
/returns error mask
*/
void clearNotAddedList(){strcpy(notAddedList,"");};
protected:
/** Error Mask */
int64_t errorMask;
/** Detectors Not added List */
char notAddedList[MAX_STR_LENGTH];
};
#endif /* ERROR_DEFS_H_ */

View File

@ -1,5 +1,6 @@
#include "ClientInterface.h"
#include "ClientSocket.h"
#include <cstring>
ClientInterface::ClientInterface(sls::ClientSocket *socket, int n) : socket_(socket){}

View File

@ -20,7 +20,7 @@ ClientSocket::ClientSocket(std::string stype, const std::string &host,
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags |= AI_CANONNAME;
if (getaddrinfo(host.c_str(), NULL, &hints, &result) != 0) {
if (getaddrinfo(host.c_str(), nullptr, &hints, &result) != 0) {
std::string msg = "ClientSocket cannot decode host:" + host +
" on port " + std::to_string(port) + "\n";
throw SocketError(msg);

View File

@ -108,7 +108,7 @@ ConvertHostnameToInternetAddress(const std::string &hostname) {
hints.ai_flags |= AI_CANONNAME;
struct sockaddr_in serverAddr {};
if (getaddrinfo(hostname.c_str(), NULL, &hints, &result) != 0) {
if (getaddrinfo(hostname.c_str(), nullptr, &hints, &result) != 0) {
freeaddrinfo(result);
std::string msg = "ClientSocket cannot decode host:" + hostname + "\n";
throw SocketError(msg);
@ -129,13 +129,13 @@ int ConvertHostnameToInternetAddress(const char *const hostname,
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
// get host info into res
int errcode = getaddrinfo(hostname, NULL, &hints, res);
int errcode = getaddrinfo(hostname, nullptr, &hints, res);
if (errcode != 0) {
FILE_LOG(logERROR) << "Could not convert hostname (" << hostname
<< ") to internet address (zmq):"
<< gai_strerror(errcode);
} else {
if (*res == NULL) {
if (*res == nullptr) {
FILE_LOG(logERROR) << "Could not converthostname (" << hostname
<< ") to internet address (zmq):"
"gettaddrinfo returned null";
@ -160,7 +160,7 @@ int ConvertInternetAddresstoIpString(struct ::addrinfo *res, char *ip,
const int ipsize) {
if (inet_ntop(res->ai_family,
&((struct sockaddr_in *)res->ai_addr)->sin_addr, ip,
ipsize) != NULL) {
ipsize) != nullptr) {
::freeaddrinfo(res);
return 0;
}

View File

@ -6,10 +6,10 @@
#include "string_utils.h"
#include <arpa/inet.h>
#include <cstring>
#include <iostream>
#include <stdexcept>
#include <unistd.h>
#include <cstring>
#define DEFAULT_PACKET_SIZE 1286
#define SOCKET_BUFFER_SIZE (100 * 1024 * 1024) // 100 MB
#define DEFAULT_BACKLOG 5

View File

@ -83,7 +83,7 @@ uint32_t HostnameToIp(const char *hostname) {
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
if (getaddrinfo(hostname, NULL, &hints, &result)) {
if (getaddrinfo(hostname, nullptr, &hints, &result)) {
freeaddrinfo(result);
throw RuntimeError("Could not convert hostname to ip");
}

View File

@ -1,5 +1,4 @@
#include "ClientInterface.h"
#include "MySocketTCP.h"
#include "catch.hpp"
//tests to add

View File

@ -1,9 +1,9 @@
#include "ClientSocket.h"
#include "ServerSocket.h"
#include "catch.hpp"
#include <chrono>
#include <future>
#include <iostream>
#include <chrono>
std::vector<char> server() {
std::cout << "starting server\n";

View File

@ -4,8 +4,8 @@
#include <iostream>
#include <vector>
#include "string_utils.h"
#include "sls_detector_exceptions.h"
#include "string_utils.h"
using namespace sls;

View File

@ -1,4 +1,3 @@
#include "MySocketTCP.h"
#include "catch.hpp"
#include "logger.h"
#include <iostream>