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

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

View File

@ -19,18 +19,18 @@ It is linked in manual/manual-api from slsReceiverSoftware/include ]
#include "sls_detector_defs.h"
#include "slsReceiverUsers.h"
#include <iostream>
#include <string.h>
#include <signal.h> //SIGINT
#include <csignal> //SIGINT
#include <cstdlib> //system
#include <cstring>
#include <iostream>
//#include "utilities.h"
//#include "logger.h"
#include <cerrno>
#include <string>
#include <sys/types.h> //wait
#include <sys/wait.h> //wait
#include <string>
#include <unistd.h> //usleep
#include <errno.h>
#include <syscall.h> //tid
#include <unistd.h> //usleep
using namespace std;

View File

@ -7,12 +7,9 @@
#include <string>
#include <vector>
#include "error_defs.h"
#include "multiSlsDetector.h"
#include "slsDetector.h"
// #include "slsDetectorUtils.h"
#include "sls_detector_defs.h"
// #include "sls_receiver_defs.h"
class Detector {
public:

View File

@ -81,7 +81,6 @@ LATEX_HIDE_INDICES = YES
PREDEFINED = __cplusplus
INPUT = ../slsSupportLib/include/communication_funcs.h \
../slsSupportLib/include/error_defs.h \
../slsSupportLib/include/sls_detector_defs.h \
../slsSupportLib/include/sls_detector_funcs.h \
../slsSupportLib/include/ansi.h \

View File

@ -1,7 +1,6 @@
#pragma once
#include "SharedMemory.h"
#include "error_defs.h"
#include "logger.h"
#include "sls_detector_defs.h"

View File

@ -2,7 +2,6 @@
#include "ClientSocket.h"
#include "SharedMemory.h"
#include "error_defs.h"
#include "logger.h"
#include "sls_detector_defs.h"
#include "network_utils.h"
@ -16,7 +15,6 @@ class ClientInterface;
class multiSlsDetector;
class ServerInterface;
class MySocketTCP;
#define SLS_SHMVERSION 0x190503
#define MAX_RX_DBIT 64

View File

@ -12,8 +12,8 @@
#include "container_utils.h"
#include "string_utils.h"
#include "network_utils.h"
#include "string_utils.h"
#include <cstring>
#include <iomanip>

View File

@ -1,7 +1,6 @@
#include "slsDetector.h"
#include "ClientInterface.h"
#include "ClientSocket.h"
#include "MySocketTCP.h"
#include "ServerInterface.h"
#include "SharedMemory.h"
#include "file_utils.h"

View File

@ -3439,7 +3439,7 @@ std::string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int acti
ret = myDet->setDynamicRange(val, detPos);
} else if (cmd == "roi") {
const ROI* r = myDet->getROI(ret, detPos);
if (r != NULL)
delete [] r;
} else if (cmd == "detsizechan") {
sprintf(ans, "%d %d", myDet->getMaxNumberOfChannelsPerDetector(X), myDet->getMaxNumberOfChannelsPerDetector(Y));

View File

@ -53,7 +53,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
* Destructor
* Calls Base Class DestroyThread() and decrements NumberofDataProcessors
*/
~DataProcessor();
~DataProcessor() override;
//*** getters ***
@ -61,7 +61,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
* Returns if the thread is currently running
* @returns true if thread is running, else false
*/
bool IsRunning();
bool IsRunning() override;
/**
* Get acquisition started flag
@ -170,7 +170,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
void SetupFileWriter(bool fwe, int* nd, uint32_t* maxf, char* fname,
char* fpath, uint64_t* findex,
bool* owenable, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr,
uint32_t* portno, GeneralData* g = 0);
uint32_t* portno, GeneralData* g = nullptr);
/**
* Create New File
@ -231,7 +231,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
* Get Type
* @return type
*/
std::string GetType();
std::string GetType() override;
/**
* Record First Indices (firstAcquisitionIndex, firstMeasurementIndex)
@ -250,7 +250,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
* Pop bound addresses, process them,
* write to file if needed & free the address
*/
void ThreadExecution();
void ThreadExecution() override;
/**
* Frees dummy buffer,

View File

@ -5,8 +5,8 @@
***********************************************/
#include "BinaryFile.h"
#include "receiver_defs.h"
#include "Fifo.h"
#include "receiver_defs.h"
#include <iostream>

View File

@ -7,18 +7,18 @@
#include "DataProcessor.h"
#include "GeneralData.h"
#include "Fifo.h"
#include "BinaryFile.h"
#include "Fifo.h"
#include "GeneralData.h"
#ifdef HDF5C
#include "HDF5File.h"
#endif
#include "DataStreamer.h"
#include "sls_detector_exceptions.h"
#include <iostream>
#include <errno.h>
#include <cerrno>
#include <cstring>
#include <iostream>
const std::string DataProcessor::TypeName = "DataProcessor";
@ -31,7 +31,7 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo* f,
std::vector <int> * cdl, int* cdo, int* cad) :
ThreadObject(ind),
runningFlag(0),
runningFlag(false),
generalData(nullptr),
fifo(f),
myDetectorType(dtype),
@ -74,8 +74,8 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo* f,
DataProcessor::~DataProcessor() {
if (file) delete file;
if (tempBuffer) delete [] tempBuffer;
delete file;
delete [] tempBuffer;
ThreadObject::DestroyThread();
}
@ -145,7 +145,7 @@ void DataProcessor::ResetParametersforNewMeasurement(){
firstMeasurementIndex = 0;
measurementStartedFlag = false;
if (tempBuffer) {
if (tempBuffer != nullptr) {
delete [] tempBuffer;
tempBuffer = nullptr;
}
@ -177,7 +177,7 @@ void DataProcessor::RecordFirstIndices(uint64_t fnum) {
void DataProcessor::SetGeneralData(GeneralData* g) {
generalData = g;
generalData->Print();
if (file) {
if (file != nullptr) {
if (file->GetFileType() == HDF5) {
file->SetNumberofPixels(generalData->nPixelsX, generalData->nPixelsY);
}
@ -196,7 +196,7 @@ int DataProcessor::SetThreadPriority(int priority) {
void DataProcessor::SetFileFormat(const fileFormat f) {
if (file && file->GetFileType() != f) {
if ((file != nullptr) && file->GetFileType() != f) {
//remember the pointer values before they are destroyed
int nd[MAX_DIMENSIONS];nd[0] = 0; nd[1] = 0;
uint32_t* maxf = nullptr;
@ -219,11 +219,11 @@ void DataProcessor::SetupFileWriter(bool fwe, int* nd, uint32_t* maxf,
GeneralData* g)
{
fileWriteEnable = fwe;
if (g)
if (g != nullptr)
generalData = g;
if (file) {
if (file != nullptr) {
delete file; file = nullptr;
}
@ -263,12 +263,12 @@ int DataProcessor::CreateNewFile(bool en, uint64_t nf, uint64_t at, uint64_t st,
void DataProcessor::CloseFiles() {
if (file)
if (file != nullptr)
file->CloseAllFiles();
}
void DataProcessor::EndofAcquisition(bool anyPacketsCaught, uint64_t numf) {
if (file && file->GetFileType() == HDF5) {
if ((file != nullptr) && file->GetFileType() == HDF5) {
file->EndofAcquisition(anyPacketsCaught, numf);
}
}
@ -281,7 +281,7 @@ void DataProcessor::ThreadExecution() {
"pop 0x" << std::hex << (void*)(buffer) << std::dec << ":" << buffer;
//check dummy
uint32_t numBytes = (uint32_t)(*((uint32_t*)buffer));
auto numBytes = (uint32_t)(*((uint32_t*)buffer));
FILE_LOG(logDEBUG1) << "DataProcessor " << index << ", Numbytes:" << numBytes;
if (numBytes == DUMMY_PACKET_VALUE) {
StopProcessing(buffer);
@ -307,7 +307,7 @@ void DataProcessor::StopProcessing(char* buf) {
else
fifo->FreeAddress(buf);
if (file)
if (file != nullptr)
file->CloseCurrentFile();
StopRunning();
FILE_LOG(logDEBUG1) << index << ": Processing Completed";
@ -316,7 +316,7 @@ void DataProcessor::StopProcessing(char* buf) {
void DataProcessor::ProcessAnImage(char* buf) {
sls_receiver_header* rheader = (sls_receiver_header*) (buf + FIFO_HEADER_NUMBYTES);
auto* rheader = (sls_receiver_header*) (buf + FIFO_HEADER_NUMBYTES);
sls_detector_header header = rheader->detHeader;
uint64_t fnum = header.frameNumber;
currentFrameIndex = fnum;
@ -361,7 +361,7 @@ void DataProcessor::ProcessAnImage(char* buf) {
}
// normal call back
if (rawDataReadyCallBack) {
if (rawDataReadyCallBack != nullptr) {
rawDataReadyCallBack(
(char*)rheader,
buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header),
@ -370,8 +370,8 @@ void DataProcessor::ProcessAnImage(char* buf) {
}
// call back with modified size
else if (rawDataModifyReadyCallBack) {
uint32_t revsize = (uint32_t)(*((uint32_t*)buf));
else if (rawDataModifyReadyCallBack != nullptr) {
auto revsize = (uint32_t)(*((uint32_t*)buf));
rawDataModifyReadyCallBack(
(char*)rheader,
buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header),
@ -382,7 +382,7 @@ void DataProcessor::ProcessAnImage(char* buf) {
// write to file
if (file)
if (file != nullptr)
file->WriteToFile(buf + FIFO_HEADER_NUMBYTES,
sizeof(sls_receiver_header) + (uint32_t)(*((uint32_t*)buf)), //+ size of data (resizable from previous call back
fnum-firstMeasurementIndex, nump);
@ -393,7 +393,7 @@ void DataProcessor::ProcessAnImage(char* buf) {
bool DataProcessor::SendToStreamer() {
//skip
if (!(*streamingFrequency)) {
if ((*streamingFrequency) == 0u) {
if (!CheckTimer())
return false;
} else {
@ -433,7 +433,7 @@ bool DataProcessor::CheckCount() {
void DataProcessor::SetPixelDimension() {
if (file) {
if (file != nullptr) {
if (file->GetFileType() == HDF5) {
file->SetNumberofPixels(generalData->nPixelsX, generalData->nPixelsY);
}
@ -456,7 +456,7 @@ void DataProcessor::PadMissingPackets(char* buf) {
FILE_LOG(logDEBUG) << index << ": Padding Missing Packets";
uint32_t pperFrame = generalData->packetsPerFrame;
sls_receiver_header* header = (sls_receiver_header*) (buf + FIFO_HEADER_NUMBYTES);
auto* header = (sls_receiver_header*) (buf + FIFO_HEADER_NUMBYTES);
uint32_t nmissing = pperFrame - header->detHeader.packetNumber;
sls_bitset pmask = header->packetsMask;
@ -472,7 +472,7 @@ void DataProcessor::PadMissingPackets(char* buf) {
continue;
// done with padding, exit loop earlier
if (!nmissing)
if (nmissing == 0u)
break;
FILE_LOG(logDEBUG) << "padding for " << index << " for pnum: " << pnum << std::endl;
@ -482,7 +482,7 @@ void DataProcessor::PadMissingPackets(char* buf) {
//for gotthard, 1st packet: 4 bytes fnum, CACA + CACA, 639*2 bytes data
// 2nd packet: 4 bytes fnum, previous 1*2 bytes data + 640*2 bytes data !!
case GOTTHARD:
if(!pnum)
if(pnum == 0u)
memset(buf + fifohsize + (pnum * dsize), 0xFF, dsize-2);
else
memset(buf + fifohsize + (pnum * dsize), 0xFF, dsize+2);
@ -507,7 +507,7 @@ void DataProcessor::RearrangeDbitData(char* buf) {
int ctbDigitalDataBytes = totalSize - (*ctbAnalogDataBytes) - (*ctbDbitOffset);
// no digital data
if (!ctbDigitalDataBytes) {
if (ctbDigitalDataBytes == 0) {
FILE_LOG(logWARNING) << "No digital data for call back, yet dbitlist is not empty.";
return;
}
@ -521,7 +521,7 @@ void DataProcessor::RearrangeDbitData(char* buf) {
memset(result, 0, numResult32Bits * sizeof(uint32_t));
uint32_t* dest = result;
uint64_t* source = (uint64_t*)(buf + digOffset + (*ctbDbitOffset));
auto* source = (uint64_t*)(buf + digOffset + (*ctbDbitOffset));
// loop through digital bit enable vector
int bitoffset = 0;
@ -566,7 +566,7 @@ void DataProcessor::InsertGapPixels(char* buf, uint32_t dr) {
const uint32_t b1px = generalData->imageSize / (npx); // not double as not dealing with 4 bit mode
const uint32_t b2px = 2 * b1px;
const uint32_t b1pxofst = (index ? b1px : 0); // left fpga (index 0) has no extra 1px offset, but right fpga has
const uint32_t b1pxofst = (index != 0 ? b1px : 0); // left fpga (index 0) has no extra 1px offset, but right fpga has
const uint32_t b1chip = 256 * b1px;
const uint32_t b1line = (nx * b1px);
@ -596,7 +596,7 @@ void DataProcessor::InsertGapPixels(char* buf, uint32_t dr) {
dstgp1 = srcgp1 + b1px;
srcgp2 = srcgp1 + b3px;
dstgp2 = dstgp1 + b1px;
if (!index) {
if (index == 0u) {
srcgp3 = srcptr + b1line - b2px;
dstgp3 = srcgp3 + b1px;
} else {

View File

@ -5,13 +5,13 @@
#include "DataStreamer.h"
#include "GeneralData.h"
#include "Fifo.h"
#include "GeneralData.h"
#include "ZmqSocket.h"
#include "sls_detector_exceptions.h"
#include <cerrno>
#include <iostream>
#include <errno.h>
const std::string DataStreamer::TypeName = "DataStreamer";
@ -46,7 +46,7 @@ DataStreamer::DataStreamer(int ind, Fifo* f, uint32_t* dr, std::vector<ROI>* r,
DataStreamer::~DataStreamer() {
CloseZmqSocket();
if (completeBuffer) delete [] completeBuffer;
delete [] completeBuffer;
ThreadObject::DestroyThread();
}

View File

@ -8,9 +8,9 @@
#include "Fifo.h"
#include "sls_detector_exceptions.h"
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <iostream>
Fifo::Fifo(int ind, uint32_t fifoItemSize, uint32_t depth):

View File

@ -7,15 +7,15 @@
#include "Listener.h"
#include "GeneralData.h"
#include "Fifo.h"
#include "genericSocket.h"
#include "GeneralData.h"
#include "container_utils.h" // For sls::make_unique<>
#include "genericSocket.h"
#include "sls_detector_exceptions.h"
#include <iostream>
#include <errno.h>
#include <cerrno>
#include <cstring>
#include <iostream>
const std::string Listener::TypeName = "Listener";

View File

@ -1,18 +1,18 @@
/* A simple server in the internet domain using TCP
The port number is passed as an argument */
#include "sls_detector_defs.h"
#include "slsReceiverUsers.h"
#include "logger.h"
#include "slsReceiverUsers.h"
#include "sls_detector_defs.h"
#include <iostream>
#include <string.h>
#include <signal.h> //SIGINT
#include <csignal> //SIGINT
#include <cstdlib> //system
#include <cstring>
#include <iostream>
#include <sys/types.h> //wait
#include <sys/wait.h> //wait
#include <unistd.h> //usleep
#include <syscall.h>
#include <unistd.h> //usleep
bool keeprunning;

View File

@ -3,21 +3,21 @@
* @short creates the UDP and TCP class objects
***********************************************/
#include <iostream>
#include <string>
#include <sstream>
#include <cstdlib>
#include <fstream>
#include <stdlib.h>
#include <map>
#include <getopt.h>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include "container_utils.h" // For sls::make_unique<>
#include "logger.h"
#include "slsReceiver.h"
#include "slsReceiverTCPIPInterface.h"
#include "sls_detector_exceptions.h"
#include "versionAPI.h"
#include "logger.h"
slsReceiver::slsReceiver(int argc, char *argv[]):
tcpipInterface (nullptr) {

View File

@ -5,20 +5,20 @@
#include "slsReceiverImplementation.h"
#include "GeneralData.h"
#include "Listener.h"
#include "DataProcessor.h"
#include "DataStreamer.h"
#include "Fifo.h"
#include "GeneralData.h"
#include "Listener.h"
#include "ZmqSocket.h" //just for the zmq port define
#include <sys/stat.h> // stat
#include <iostream>
#include <string.h>
#include <cerrno> //eperm
#include <cstdlib> //system
#include <cstring>
#include <cstring> //strcpy
#include <errno.h> //eperm
#include <fstream>
#include <iostream>
#include <sys/stat.h> // stat
/** cosntructor & destructor */

View File

@ -4,23 +4,23 @@
***********************************************/
#include "slsReceiverTCPIPInterface.h"
#include "slsReceiverImplementation.h"
#include "MySocketTCP.h"
#include "ServerInterface.h"
#include "slsReceiverUsers.h"
#include "slsReceiver.h"
#include "slsReceiverImplementation.h"
#include "slsReceiverUsers.h"
#include "versionAPI.h"
#include <stdlib.h> //EXIT
#include <iostream>
#include <string>
#include <sstream>
#include <array>
#include <cstdlib> //EXIT
#include <cstdlib>
#include <fstream>
#include <stdlib.h>
#include <iostream>
#include <memory> //unique_ptr
#include <sstream>
#include <string>
#include <syscall.h>
#include <vector>
#include <array>
#include <memory> //unique_ptr
slsReceiverTCPIPInterface::~slsReceiverTCPIPInterface() {
stop();
@ -28,9 +28,9 @@ slsReceiverTCPIPInterface::~slsReceiverTCPIPInterface() {
delete mySock;
mySock=nullptr;
}
if (interface)
delete interface;
if(receiver)
delete receiver;
}

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>