mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-06 01:50:40 +02:00
clang format on receiver TCP and Implementation
This commit is contained in:
parent
3d6404952a
commit
72e0d7e168
@ -1,15 +1,19 @@
|
||||
#pragma once
|
||||
/********************************************/ /**
|
||||
* @file slsReceiverImplementation.h
|
||||
* @short does all the functions for a receiver, set/get parameters, start/stop etc.
|
||||
* @file
|
||||
*slsReceiverImplementation.h
|
||||
* @short does all the functions
|
||||
*for a receiver, set/get
|
||||
*parameters, start/stop etc.
|
||||
***********************************************/
|
||||
/**
|
||||
* @short does all the functions for a receiver, set/get parameters, start/stop etc.
|
||||
* @short does all the functions for a receiver, set/get parameters, start/stop
|
||||
* etc.
|
||||
*/
|
||||
// #include "sls_detector_defs.h"
|
||||
#include "receiver_defs.h"
|
||||
#include "logger.h"
|
||||
#include "container_utils.h"
|
||||
#include "logger.h"
|
||||
#include "receiver_defs.h"
|
||||
class GeneralData;
|
||||
class Listener;
|
||||
class DataProcessor;
|
||||
@ -18,13 +22,11 @@ class Fifo;
|
||||
class slsDetectorDefs;
|
||||
|
||||
#include <exception>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class slsReceiverImplementation : private virtual slsDetectorDefs {
|
||||
public:
|
||||
|
||||
|
||||
//*** cosntructor & destructor ***
|
||||
/**
|
||||
* Constructor
|
||||
@ -36,7 +38,6 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
*/
|
||||
virtual ~slsReceiverImplementation();
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Getters ***************************************************************
|
||||
* They access local cache of configuration or detector parameters *******
|
||||
@ -79,7 +80,6 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
*/
|
||||
readOutFlags getReadOutFlags() const;
|
||||
|
||||
|
||||
//***file parameters***
|
||||
/**
|
||||
* Get File Format
|
||||
@ -87,7 +87,8 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
*/
|
||||
fileFormat getFileFormat() const;
|
||||
/**
|
||||
* Get File Name Prefix (without frame index, file index and extension (_d0_f000000000000_8.raw))
|
||||
* Get File Name Prefix (without frame index, file index and extension
|
||||
* (_d0_f000000000000_8.raw))
|
||||
* @return file name prefix
|
||||
*/
|
||||
std::string getFileName() const;
|
||||
@ -140,7 +141,6 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
*/
|
||||
bool getOverwriteEnable() const;
|
||||
|
||||
|
||||
//***acquisition count parameters***
|
||||
/**
|
||||
* Get Total Frames Caught for an entire acquisition (including all scans)
|
||||
@ -156,11 +156,11 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
|
||||
/**
|
||||
* Get Current Frame Index for an entire acquisition (including all scans)
|
||||
* @return 0 if no frames have been caught, else average of all current frame index
|
||||
* @return 0 if no frames have been caught, else average of all current
|
||||
* frame index
|
||||
*/
|
||||
uint64_t getAcquisitionIndex() const;
|
||||
|
||||
|
||||
//***connection parameters***
|
||||
/**
|
||||
* Get UDP Port Number
|
||||
@ -192,7 +192,6 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
*/
|
||||
int getNumberofUDPInterfaces() const;
|
||||
|
||||
|
||||
//***acquisition parameters***
|
||||
/**
|
||||
* Get ROI
|
||||
@ -224,7 +223,6 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
*/
|
||||
bool getDataStreamEnable() const;
|
||||
|
||||
|
||||
/**
|
||||
* Get Acquisition Period
|
||||
* @return acquisition period
|
||||
@ -251,19 +249,22 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
|
||||
/*
|
||||
* Get Number of Frames expected by receiver from detector
|
||||
* The data receiver status will change from running to idle when it gets this number of frames FIXME: (Not implemented)
|
||||
* The data receiver status will change from running to idle when it gets
|
||||
* this number of frames FIXME: (Not implemented)
|
||||
* @return number of frames expected
|
||||
*/
|
||||
uint64_t getNumberOfFrames() const;
|
||||
|
||||
/*
|
||||
* Get Number of Analog Samples expected by receiver from detector (for chip test board and moench only)
|
||||
* Get Number of Analog Samples expected by receiver from detector (for chip
|
||||
* test board and moench only)
|
||||
* @return number of Analog samples expected
|
||||
*/
|
||||
uint64_t getNumberofAnalogSamples() const;
|
||||
|
||||
/*
|
||||
* Get Number of Digital Samples expected by receiver from detector (for chip test board and moench only)
|
||||
* Get Number of Digital Samples expected by receiver from detector (for
|
||||
* chip test board and moench only)
|
||||
* @return number of Digital samples expected
|
||||
*/
|
||||
uint64_t getNumberofDigitalSamples() const;
|
||||
@ -286,11 +287,11 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
*/
|
||||
uint32_t getFifoDepth() const;
|
||||
|
||||
|
||||
//***receiver status***
|
||||
/**
|
||||
* Get Listening Status of Receiver
|
||||
* @return can be idle, listening or error depending on if the receiver is listening or not
|
||||
* @return can be idle, listening or error depending on if the receiver is
|
||||
* listening or not
|
||||
*/
|
||||
runStatus getStatus() const;
|
||||
|
||||
@ -314,16 +315,16 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
|
||||
/**
|
||||
* Get activate
|
||||
* If deactivated, receiver will create dummy data if deactivated padding is enabled
|
||||
* (as it will receive nothing from detector)
|
||||
* If deactivated, receiver will create dummy data if deactivated padding is
|
||||
* enabled (as it will receive nothing from detector)
|
||||
* @return false for deactivated, true for activated
|
||||
*/
|
||||
bool getActivate() const;
|
||||
|
||||
/**
|
||||
* Get deactivated padding enable
|
||||
* If enabled, receiver will create dummy packets (0xFF), else it will create nothing
|
||||
* (as it will receive nothing from detector)
|
||||
* If enabled, receiver will create dummy packets (0xFF), else it will
|
||||
* create nothing (as it will receive nothing from detector)
|
||||
* @return 0 for disabled, 1 for enabled
|
||||
*/
|
||||
bool getDeactivatedPadding() const;
|
||||
@ -352,7 +353,6 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
*/
|
||||
int64_t getUDPSocketBufferSize() const;
|
||||
|
||||
|
||||
/** (not saved in client shared memory)
|
||||
* Get actual UDP Socket Buffer Size
|
||||
* @return actual UDP Socket Buffer Size
|
||||
@ -397,7 +397,6 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
*/
|
||||
int setReadOutFlags(const readOutFlags f);
|
||||
|
||||
|
||||
//***file parameters***
|
||||
/**
|
||||
* Set File Format
|
||||
@ -406,8 +405,9 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
void setFileFormat(slsDetectorDefs::fileFormat f);
|
||||
|
||||
/**
|
||||
* Set File Name Prefix (without frame index, file index and extension (_d0_f000000000000_8.raw))
|
||||
* Does not check for file existence since it is created only at startReceiver
|
||||
* Set File Name Prefix (without frame index, file index and extension
|
||||
* (_d0_f000000000000_8.raw)) Does not check for file existence since it is
|
||||
* created only at startReceiver
|
||||
* @param c file name (max of 1000 characters)
|
||||
*/
|
||||
void setFileName(const char c[]);
|
||||
@ -501,7 +501,6 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
*/
|
||||
int setUDPSocketBufferSize(const int64_t s);
|
||||
|
||||
|
||||
//***acquisition parameters***
|
||||
/**
|
||||
* Set ROI
|
||||
@ -583,7 +582,8 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
|
||||
/**
|
||||
* Set Number of Frames expected by receiver from detector
|
||||
* The data receiver status will change from running to idle when it gets this number of frames
|
||||
* The data receiver status will change from running to idle when it gets
|
||||
* this number of frames
|
||||
* @param i number of frames expected
|
||||
*/
|
||||
void setNumberOfFrames(const uint64_t i);
|
||||
@ -623,12 +623,11 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
*/
|
||||
int setFifoDepth(const uint32_t i);
|
||||
|
||||
|
||||
//***receiver parameters***
|
||||
/**
|
||||
* Activate / Deactivate Receiver
|
||||
* If deactivated, receiver will create dummy data if deactivated padding is enabled
|
||||
* (as it will receive nothing from detector)
|
||||
* If deactivated, receiver will create dummy data if deactivated padding is
|
||||
* enabled (as it will receive nothing from detector)
|
||||
* @param enable enable
|
||||
* @return false for disabled, true for enabled
|
||||
*/
|
||||
@ -636,8 +635,8 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
|
||||
/**
|
||||
* Set deactivated padding enable
|
||||
* If enabled, receiver will create dummy packets (0xFF), else it will create nothing
|
||||
* (as it will receive nothing from detector)
|
||||
* If enabled, receiver will create dummy packets (0xFF), else it will
|
||||
* create nothing (as it will receive nothing from detector)
|
||||
* @param enable enable
|
||||
* @return false for disabled, true for enabled
|
||||
*/
|
||||
@ -661,7 +660,6 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
*/
|
||||
void setDbitOffset(const int s);
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Behavioral functions***************************************************
|
||||
* They may modify the status of the receiver ****************************
|
||||
@ -669,8 +667,9 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
|
||||
//***initial functions***
|
||||
/**
|
||||
* Set receiver type (and corresponding detector variables in derived STANDARD class)
|
||||
* It is the first function called by the client when connecting to receiver
|
||||
* Set receiver type (and corresponding detector variables in derived
|
||||
* STANDARD class) It is the first function called by the client when
|
||||
* connecting to receiver
|
||||
* @param d detector type
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
@ -684,13 +683,15 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
|
||||
//***acquisition functions***
|
||||
/**
|
||||
* Reset acquisition parameters such as total frames caught for an entire acquisition (including all scans)
|
||||
* Reset acquisition parameters such as total frames caught for an entire
|
||||
* acquisition (including all scans)
|
||||
*/
|
||||
void resetAcquisitionCount();
|
||||
|
||||
/**
|
||||
* Start Listening for Packets by activating all configuration settings to receiver
|
||||
* When this function returns, it has status RUNNING(upon SUCCESS) or IDLE (upon failure)
|
||||
* Start Listening for Packets by activating all configuration settings to
|
||||
* receiver When this function returns, it has status RUNNING(upon SUCCESS)
|
||||
* or IDLE (upon failure)
|
||||
* @param c error message if FAIL
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
@ -698,20 +699,21 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
|
||||
/**
|
||||
* Stop Listening for Packets
|
||||
* Calls startReadout(), which stops listening and sets status to Transmitting
|
||||
* When it has read every frame in buffer, the status changes to Run_Finished
|
||||
* When this function returns, receiver has status IDLE
|
||||
* Pre: status is running, semaphores have been instantiated,
|
||||
* Post: udp sockets shut down, status is idle, semaphores destroyed
|
||||
* Calls startReadout(), which stops listening and sets status to
|
||||
* Transmitting When it has read every frame in buffer, the status changes
|
||||
* to Run_Finished When this function returns, receiver has status IDLE Pre:
|
||||
* status is running, semaphores have been instantiated, Post: udp sockets
|
||||
* shut down, status is idle, semaphores destroyed
|
||||
*/
|
||||
void stopReceiver();
|
||||
|
||||
/**
|
||||
* Stop Listening to Packets
|
||||
* and sets status to Transmitting
|
||||
* Next step would be to get all data and stop receiver completely and return with idle state
|
||||
* Pre: status is running, udp sockets have been initialized, stop receiver initiated
|
||||
* Post:udp sockets closed, status is transmitting
|
||||
* Next step would be to get all data and stop receiver completely and
|
||||
* return with idle state Pre: status is running, udp sockets have been
|
||||
* initialized, stop receiver initiated Post:udp sockets closed, status is
|
||||
* transmitting
|
||||
*/
|
||||
void startReadout();
|
||||
|
||||
@ -745,14 +747,17 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
* we write depending on file write enable
|
||||
* users get data to write depending on call backs registered
|
||||
*/
|
||||
void registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg);
|
||||
void registerCallBackStartAcquisition(int (*func)(char *, char *, uint64_t,
|
||||
uint32_t, void *),
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* Call back for acquisition finished
|
||||
* callback argument is
|
||||
* 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
|
||||
@ -761,8 +766,9 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
* dataPointer is the pointer to the data
|
||||
* dataSize in bytes is the size of the data in bytes.
|
||||
*/
|
||||
void registerCallBackRawDataReady(void (*func)(char* ,
|
||||
char*, uint32_t, void*),void *arg);
|
||||
void registerCallBackRawDataReady(void (*func)(char *, char *, uint32_t,
|
||||
void *),
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* Call back for raw data (modified)
|
||||
@ -770,13 +776,14 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
* sls_receiver_header frame metadata
|
||||
* dataPointer is the pointer to the data
|
||||
* 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* ,
|
||||
char*, uint32_t &,void*),void *arg);
|
||||
void registerCallBackRawDataModifyReady(void (*func)(char *, char *,
|
||||
uint32_t &, void *),
|
||||
void *arg);
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Delete and free member parameters
|
||||
*/
|
||||
@ -829,8 +836,6 @@ private:
|
||||
*/
|
||||
void StartRunning();
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Class Members *********************************************************
|
||||
*************************************************************************/
|
||||
@ -909,7 +914,8 @@ private:
|
||||
//***file parameters***
|
||||
/** File format */
|
||||
fileFormat fileFormatType;
|
||||
/** File Name without frame index, file index and extension (_d0_f000000000000_8.raw)*/
|
||||
/** File Name without frame index, file index and extension
|
||||
* (_d0_f000000000000_8.raw)*/
|
||||
char fileName[MAX_STR_LENGTH];
|
||||
/** File Path */
|
||||
char filePath[MAX_STR_LENGTH];
|
||||
@ -983,20 +989,16 @@ private:
|
||||
* dataPointer is the pointer to the data
|
||||
* dataSize in bytes is the size of the data in bytes.
|
||||
*/
|
||||
void (*rawDataReadyCallBack)(char* ,
|
||||
char*, uint32_t, void*);
|
||||
void (*rawDataReadyCallBack)(char *, char *, uint32_t, void *);
|
||||
/**
|
||||
* Call back for raw data (modified)
|
||||
* args to raw data ready callback are
|
||||
* sls_receiver_header frame metadata
|
||||
* dataPointer is the pointer to the data
|
||||
* revDatasize is the reference of data size in bytes. Can be modified to the new size to be written/streamed. (only smaller value).
|
||||
* revDatasize is the reference of data size in bytes. Can be modified to
|
||||
* the new size to be written/streamed. (only smaller value).
|
||||
*/
|
||||
void (*rawDataModifyReadyCallBack)(char* ,
|
||||
char*, uint32_t &, void*);
|
||||
void (*rawDataModifyReadyCallBack)(char *, char *, uint32_t &, void *);
|
||||
|
||||
void *pRawDataReady;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
@ -1,18 +1,18 @@
|
||||
#pragma once
|
||||
/********************************************/ /**
|
||||
* @file slsReceiverTCPIPInterface.h
|
||||
* @short interface between receiver and client
|
||||
* @file
|
||||
*slsReceiverTCPIPInterface.h
|
||||
* @short interface between
|
||||
*receiver and client
|
||||
***********************************************/
|
||||
|
||||
|
||||
#include "sls_detector_defs.h"
|
||||
#include "receiver_defs.h"
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
class MySocketTCP;
|
||||
class ServerInterface;
|
||||
#include "slsReceiverImplementation.h"
|
||||
#include "ServerSocket.h"
|
||||
|
||||
#include "slsReceiverImplementation.h"
|
||||
|
||||
/**
|
||||
*@short interface between receiver and client
|
||||
@ -23,7 +23,6 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
||||
enum numberMode { DEC, HEX };
|
||||
|
||||
public:
|
||||
|
||||
/** Destructor */
|
||||
virtual ~slsReceiverTCPIPInterface();
|
||||
|
||||
@ -45,7 +44,6 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
||||
/** stop listening on the TCP & UDP port for client comminication */
|
||||
void stop();
|
||||
|
||||
|
||||
/** gets version */
|
||||
int64_t getReceiverVersion();
|
||||
|
||||
@ -62,14 +60,17 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
||||
* we write depending on file write enable
|
||||
* users get data to write depending on call backs registered
|
||||
*/
|
||||
void registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg);
|
||||
void registerCallBackStartAcquisition(int (*func)(char *, char *, uint64_t,
|
||||
uint32_t, void *),
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* Call back for acquisition finished
|
||||
* callback argument is
|
||||
* 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
|
||||
@ -78,8 +79,9 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
||||
* dataPointer is the pointer to the data
|
||||
* dataSize in bytes is the size of the data in bytes.
|
||||
*/
|
||||
void registerCallBackRawDataReady(void (*func)(char* ,
|
||||
char*, uint32_t, void*),void *arg);
|
||||
void registerCallBackRawDataReady(void (*func)(char *, char *, uint32_t,
|
||||
void *),
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* Call back for raw data (modified)
|
||||
@ -87,14 +89,14 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
||||
* sls_receiver_header frame metadata
|
||||
* dataPointer is the pointer to the data
|
||||
* 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* ,
|
||||
char*, uint32_t &,void*),void *arg);
|
||||
|
||||
void registerCallBackRawDataModifyReady(void (*func)(char *, char *,
|
||||
uint32_t &, void *),
|
||||
void *arg);
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Static function - Thread started which is a TCP server
|
||||
* Called by start()
|
||||
@ -102,7 +104,6 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
||||
*/
|
||||
static void *startTCPServerThread(void *this_pointer);
|
||||
|
||||
|
||||
/**
|
||||
* Thread started which is a TCP server
|
||||
* Called by start()
|
||||
@ -300,7 +301,8 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
||||
std::unique_ptr<slsReceiverImplementation> receiver{nullptr};
|
||||
|
||||
/** Function List */
|
||||
int (slsReceiverTCPIPInterface::*flist[NUM_REC_FUNCTIONS])(sls::ServerInterface2& socket);
|
||||
int (slsReceiverTCPIPInterface::*flist[NUM_REC_FUNCTIONS])(
|
||||
sls::ServerInterface2 &socket);
|
||||
|
||||
/** Message */
|
||||
char mess[MAX_STR_LENGTH]{};
|
||||
@ -339,7 +341,8 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
||||
* we write depending on file write enable
|
||||
* users get data to write depending on call backs registered
|
||||
*/
|
||||
int (*startAcquisitionCallBack)(char*, char*, uint64_t, uint32_t, void*) = nullptr;
|
||||
int (*startAcquisitionCallBack)(char *, char *, uint64_t, uint32_t,
|
||||
void *) = nullptr;
|
||||
void *pStartAcquisition{nullptr};
|
||||
|
||||
/**
|
||||
@ -350,7 +353,6 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
||||
void (*acquisitionFinishedCallBack)(uint64_t, void *) = nullptr;
|
||||
void *pAcquisitionFinished{nullptr};
|
||||
|
||||
|
||||
/**
|
||||
* Call back for raw data
|
||||
* args to raw data ready callback are
|
||||
@ -358,26 +360,22 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
||||
* dataPointer is the pointer to the data
|
||||
* dataSize in bytes is the size of the data in bytes.
|
||||
*/
|
||||
void (*rawDataReadyCallBack)(char* ,
|
||||
char*, uint32_t, void*) = nullptr;
|
||||
void (*rawDataReadyCallBack)(char *, char *, uint32_t, void *) = nullptr;
|
||||
|
||||
/**
|
||||
* Call back for raw data (modified)
|
||||
* args to raw data ready callback are
|
||||
* sls_receiver_header frame metadata
|
||||
* dataPointer is the pointer to the data
|
||||
* revDatasize is the reference of data size in bytes. Can be modified to the new size to be written/streamed. (only smaller value).
|
||||
* revDatasize is the reference of data size in bytes. Can be modified to
|
||||
* the new size to be written/streamed. (only smaller value).
|
||||
*/
|
||||
void (*rawDataModifyReadyCallBack)(char* ,
|
||||
char*, uint32_t &, void*) = nullptr;
|
||||
void (*rawDataModifyReadyCallBack)(char *, char *, uint32_t &,
|
||||
void *) = nullptr;
|
||||
|
||||
void *pRawDataReady{nullptr};
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
std::unique_ptr<sls::ServerSocket> server{nullptr};
|
||||
|
||||
private:
|
||||
@ -388,7 +386,8 @@ protected:
|
||||
if (receiver != nullptr) {
|
||||
return receiver.get();
|
||||
} else {
|
||||
throw sls::SocketError("Receiver not set up. Please use rx_hostname first.\n");
|
||||
throw sls::SocketError(
|
||||
"Receiver not set up. Please use rx_hostname first.\n");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,18 +1,19 @@
|
||||
/********************************************/ /**
|
||||
* @file slsReceiverTCPIPInterface.cpp
|
||||
* @short interface between receiver and client
|
||||
* @file
|
||||
*slsReceiverTCPIPInterface.cpp
|
||||
* @short interface between
|
||||
*receiver and client
|
||||
***********************************************/
|
||||
|
||||
|
||||
#include "slsReceiverTCPIPInterface.h"
|
||||
#include "FixedCapacityContainer.h"
|
||||
#include "ServerSocket.h"
|
||||
#include "slsReceiver.h"
|
||||
#include "slsReceiverImplementation.h"
|
||||
#include "slsReceiverTCPIPInterface.h"
|
||||
#include "slsReceiverUsers.h"
|
||||
#include "versionAPI.h"
|
||||
#include "string_utils.h"
|
||||
#include "sls_detector_exceptions.h"
|
||||
#include "string_utils.h"
|
||||
#include "versionAPI.h"
|
||||
|
||||
#include <array>
|
||||
#include <cstdlib>
|
||||
@ -24,26 +25,22 @@
|
||||
#include <syscall.h>
|
||||
#include <vector>
|
||||
|
||||
using sls::SocketError;
|
||||
using sls::RuntimeError;
|
||||
using sls::SocketError;
|
||||
using Interface = sls::ServerInterface2;
|
||||
|
||||
slsReceiverTCPIPInterface::~slsReceiverTCPIPInterface() {
|
||||
stop();
|
||||
}
|
||||
slsReceiverTCPIPInterface::~slsReceiverTCPIPInterface() { stop(); }
|
||||
|
||||
slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int pn):
|
||||
myDetectorType(GOTTHARD),
|
||||
portNumber(pn > 0 ? pn : DEFAULT_PORTNO + 2)
|
||||
{
|
||||
slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int pn)
|
||||
: myDetectorType(GOTTHARD), portNumber(pn > 0 ? pn : DEFAULT_PORTNO + 2) {
|
||||
function_table();
|
||||
}
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::start() {
|
||||
FILE_LOG(logDEBUG) << "Creating TCP Server Thread";
|
||||
killTCPServerThread = 0;
|
||||
if(pthread_create(&TCPServer_thread, nullptr,startTCPServerThread, (void*) this)){
|
||||
if (pthread_create(&TCPServer_thread, nullptr, startTCPServerThread,
|
||||
(void *)this)) {
|
||||
FILE_LOG(logERROR) << "Could not create TCP Server thread";
|
||||
return FAIL;
|
||||
}
|
||||
@ -52,7 +49,6 @@ int slsReceiverTCPIPInterface::start(){
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
void slsReceiverTCPIPInterface::stop() {
|
||||
if (tcpThreadCreated) {
|
||||
FILE_LOG(logINFO) << "Shutting down TCP Socket on port " << portNumber;
|
||||
@ -63,35 +59,34 @@ void slsReceiverTCPIPInterface::stop(){
|
||||
pthread_join(TCPServer_thread, nullptr);
|
||||
tcpThreadCreated = false;
|
||||
killTCPServerThread = 0;
|
||||
FILE_LOG(logDEBUG) << "Exiting TCP Server Thread on port " << portNumber;
|
||||
FILE_LOG(logDEBUG) << "Exiting TCP Server Thread on port "
|
||||
<< portNumber;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int64_t slsReceiverTCPIPInterface::getReceiverVersion(){
|
||||
return APIRECEIVER;
|
||||
}
|
||||
int64_t slsReceiverTCPIPInterface::getReceiverVersion() { return APIRECEIVER; }
|
||||
|
||||
/***callback functions***/
|
||||
void slsReceiverTCPIPInterface::registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg){
|
||||
void slsReceiverTCPIPInterface::registerCallBackStartAcquisition(
|
||||
int (*func)(char *, char *, uint64_t, uint32_t, void *), void *arg) {
|
||||
startAcquisitionCallBack = func;
|
||||
pStartAcquisition = arg;
|
||||
}
|
||||
|
||||
void slsReceiverTCPIPInterface::registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg){
|
||||
void slsReceiverTCPIPInterface::registerCallBackAcquisitionFinished(
|
||||
void (*func)(uint64_t, void *), void *arg) {
|
||||
acquisitionFinishedCallBack = func;
|
||||
pAcquisitionFinished = arg;
|
||||
}
|
||||
|
||||
void slsReceiverTCPIPInterface::registerCallBackRawDataReady(void (*func)(char* ,
|
||||
char*, uint32_t, void*),void *arg){
|
||||
void slsReceiverTCPIPInterface::registerCallBackRawDataReady(
|
||||
void (*func)(char *, char *, uint32_t, void *), void *arg) {
|
||||
rawDataReadyCallBack = func;
|
||||
pRawDataReady = arg;
|
||||
}
|
||||
|
||||
void slsReceiverTCPIPInterface::registerCallBackRawDataModifyReady(void (*func)(char* ,
|
||||
char*, uint32_t &,void*),void *arg){
|
||||
void slsReceiverTCPIPInterface::registerCallBackRawDataModifyReady(
|
||||
void (*func)(char *, char *, uint32_t &, void *), void *arg) {
|
||||
rawDataModifyReadyCallBack = func;
|
||||
pRawDataReady = arg;
|
||||
}
|
||||
@ -102,8 +97,8 @@ void* slsReceiverTCPIPInterface::startTCPServerThread(void *this_pointer){
|
||||
}
|
||||
|
||||
void slsReceiverTCPIPInterface::startTCPServer() {
|
||||
FILE_LOG(logINFOBLUE) << "Created [ TCP server Tid: "
|
||||
<< syscall(SYS_gettid) << "]";
|
||||
FILE_LOG(logINFOBLUE) << "Created [ TCP server Tid: " << syscall(SYS_gettid)
|
||||
<< "]";
|
||||
FILE_LOG(logINFO) << "SLS Receiver starting TCP Server on port "
|
||||
<< portNumber << '\n';
|
||||
server = sls::make_unique<sls::ServerSocket>(portNumber);
|
||||
@ -122,7 +117,6 @@ void slsReceiverTCPIPInterface::startTCPServer() {
|
||||
socket.write(mess, sizeof(mess));
|
||||
}
|
||||
|
||||
|
||||
// if tcp command was to exit server
|
||||
if (ret == GOODBYE) {
|
||||
FILE_LOG(logINFO) << "Shutting down UDP Socket";
|
||||
@ -151,7 +145,7 @@ void slsReceiverTCPIPInterface::startTCPServer() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
int slsReceiverTCPIPInterface::function_table(){
|
||||
flist[F_EXEC_RECEIVER_COMMAND] = &slsReceiverTCPIPInterface::exec_command;
|
||||
flist[F_EXIT_RECEIVER] = &slsReceiverTCPIPInterface::exit_server;
|
||||
@ -215,7 +209,7 @@ int slsReceiverTCPIPInterface::function_table(){
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
// clang-format on
|
||||
int slsReceiverTCPIPInterface::decode_function(Interface &socket) {
|
||||
ret = FAIL;
|
||||
socket.receiveArg(fnum);
|
||||
@ -241,14 +235,17 @@ void slsReceiverTCPIPInterface::functionNotImplemented() {
|
||||
throw RuntimeError(mess);
|
||||
}
|
||||
|
||||
void slsReceiverTCPIPInterface::modeNotImplemented(std::string modename, int mode) {
|
||||
void slsReceiverTCPIPInterface::modeNotImplemented(std::string modename,
|
||||
int mode) {
|
||||
char message[MAX_STR_LENGTH];
|
||||
sprintf(message, "%s (%d) is not implemented for this detector\n", modename.c_str(), mode);
|
||||
sprintf(message, "%s (%d) is not implemented for this detector\n",
|
||||
modename.c_str(), mode);
|
||||
throw RuntimeError(message);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void slsReceiverTCPIPInterface::validate(T arg, T retval, std::string modename, numberMode hex) {
|
||||
void slsReceiverTCPIPInterface::validate(T arg, T retval, std::string modename,
|
||||
numberMode hex) {
|
||||
if (ret == OK && arg != -1 && retval != arg) {
|
||||
if (hex)
|
||||
sprintf(mess, "Could not %s. Set 0x%x, but read 0x%x\n",
|
||||
@ -325,11 +322,11 @@ int slsReceiverTCPIPInterface::get_last_client_ip(Interface &socket) {
|
||||
return socket.sendResult(ret, &ip, sizeof(ip));
|
||||
}
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::set_port(Interface &socket) {
|
||||
auto p_number = socket.receive<int>();
|
||||
if (p_number < 1024)
|
||||
throw RuntimeError("Port Number: " + std::to_string(p_number)+ " is too low (<1024)");
|
||||
throw RuntimeError("Port Number: " + std::to_string(p_number) +
|
||||
" is too low (<1024)");
|
||||
|
||||
FILE_LOG(logINFO) << "set port to " << p_number << std::endl;
|
||||
auto new_server = sls::make_unique<sls::ServerSocket>(p_number);
|
||||
@ -342,13 +339,12 @@ int slsReceiverTCPIPInterface::set_port(Interface &socket) {
|
||||
|
||||
int slsReceiverTCPIPInterface::update_client(Interface &socket) {
|
||||
if (receiver == nullptr)
|
||||
throw sls::SocketError("Receiver not set up. Please use rx_hostname first.\n");
|
||||
throw sls::SocketError(
|
||||
"Receiver not set up. Please use rx_hostname first.\n");
|
||||
socket.sendData(OK);
|
||||
return send_update(socket);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::send_update(Interface &socket) {
|
||||
int n = 0;
|
||||
int i32 = -1;
|
||||
@ -459,7 +455,8 @@ int slsReceiverTCPIPInterface::set_detector_type(Interface &socket){
|
||||
auto arg = socket.receive<detectorType>();
|
||||
// set
|
||||
if (arg >= 0) {
|
||||
// if object exists, verify unlocked and idle, else only verify lock (connecting first time)
|
||||
// if object exists, verify unlocked and idle, else only verify lock
|
||||
// (connecting first time)
|
||||
if (receiver != nullptr) {
|
||||
VerifyIdle(socket);
|
||||
}
|
||||
@ -485,14 +482,17 @@ int slsReceiverTCPIPInterface::set_detector_type(Interface &socket){
|
||||
|
||||
// callbacks after (in setdetectortype, the object is reinitialized)
|
||||
if (startAcquisitionCallBack)
|
||||
impl()->registerCallBackStartAcquisition(startAcquisitionCallBack,pStartAcquisition);
|
||||
impl()->registerCallBackStartAcquisition(startAcquisitionCallBack,
|
||||
pStartAcquisition);
|
||||
if (acquisitionFinishedCallBack)
|
||||
impl()->registerCallBackAcquisitionFinished(acquisitionFinishedCallBack,pAcquisitionFinished);
|
||||
impl()->registerCallBackAcquisitionFinished(
|
||||
acquisitionFinishedCallBack, pAcquisitionFinished);
|
||||
if (rawDataReadyCallBack)
|
||||
impl()->registerCallBackRawDataReady(rawDataReadyCallBack,pRawDataReady);
|
||||
impl()->registerCallBackRawDataReady(rawDataReadyCallBack,
|
||||
pRawDataReady);
|
||||
if (rawDataModifyReadyCallBack)
|
||||
impl()->registerCallBackRawDataModifyReady(rawDataModifyReadyCallBack,pRawDataReady);
|
||||
|
||||
impl()->registerCallBackRawDataModifyReady(
|
||||
rawDataModifyReadyCallBack, pRawDataReady);
|
||||
}
|
||||
return socket.sendResult(myDetectorType);
|
||||
}
|
||||
@ -514,7 +514,6 @@ int slsReceiverTCPIPInterface::set_detector_hostname(Interface &socket) {
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::set_roi(Interface &socket) {
|
||||
static_assert(sizeof(ROI) == 4 * sizeof(int), "ROI not packed");
|
||||
auto narg = socket.receive<int>();
|
||||
@ -526,9 +525,9 @@ int slsReceiverTCPIPInterface::set_roi(Interface &socket) {
|
||||
}
|
||||
FILE_LOG(logDEBUG1) << "Set ROI narg: " << narg;
|
||||
for (int iloop = 0; iloop < narg; ++iloop) {
|
||||
FILE_LOG(logDEBUG1) << "(" << arg[iloop].xmin << ", " <<
|
||||
arg[iloop].xmax << ", " << arg[iloop].ymin << ", " <<
|
||||
arg[iloop].ymax << ")";
|
||||
FILE_LOG(logDEBUG1)
|
||||
<< "(" << arg[iloop].xmin << ", " << arg[iloop].xmax << ", "
|
||||
<< arg[iloop].ymin << ", " << arg[iloop].ymax << ")";
|
||||
}
|
||||
|
||||
if (myDetectorType == EIGER || myDetectorType == JUNGFRAU)
|
||||
@ -570,7 +569,8 @@ int slsReceiverTCPIPInterface::setup_udp(Interface &socket){
|
||||
// if there is a dot in eth name
|
||||
if (strchr(eth, '.') != nullptr) {
|
||||
strcpy(eth, "");
|
||||
sprintf(mess, "Failed to get ethernet interface from IP. Got %s\n", temp.c_str());
|
||||
sprintf(mess, "Failed to get ethernet interface from IP. Got %s\n",
|
||||
temp.c_str());
|
||||
FILE_LOG(logERROR) << mess;
|
||||
}
|
||||
impl()->setEthernetInterface(eth);
|
||||
@ -604,7 +604,10 @@ int slsReceiverTCPIPInterface::setup_udp(Interface &socket){
|
||||
// if there is a dot in eth name
|
||||
if (strchr(eth, '.') != nullptr) {
|
||||
strcpy(eth, "");
|
||||
sprintf(mess, "Failed to get 2nd ethernet interface from IP. Got %s\n", temp.c_str());
|
||||
sprintf(
|
||||
mess,
|
||||
"Failed to get 2nd ethernet interface from IP. Got %s\n",
|
||||
temp.c_str());
|
||||
FILE_LOG(logERROR) << mess;
|
||||
}
|
||||
impl()->setEthernetInterface2(eth);
|
||||
@ -613,18 +616,22 @@ int slsReceiverTCPIPInterface::setup_udp(Interface &socket){
|
||||
if (ret != FAIL) {
|
||||
temp = sls::InterfaceNameToMac(eth).str();
|
||||
if (temp == "00:00:00:00:00:00") {
|
||||
throw RuntimeError("failed to get 2nd mac adddress to listen to");
|
||||
throw RuntimeError(
|
||||
"failed to get 2nd mac adddress to listen to");
|
||||
FILE_LOG(logERROR) << mess;
|
||||
} else {
|
||||
strcpy(retvals[1], temp.c_str());
|
||||
FILE_LOG(logINFO) << "Receiver MAC Address 2: " << retvals[1];
|
||||
FILE_LOG(logINFO)
|
||||
<< "Receiver MAC Address 2: " << retvals[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set the number of udp interfaces (changes number of threads and many others)
|
||||
if (myDetectorType == JUNGFRAU && impl()->setNumberofUDPInterfaces(numInterfaces) == FAIL) {
|
||||
// set the number of udp interfaces (changes number of threads and many
|
||||
// others)
|
||||
if (myDetectorType == JUNGFRAU &&
|
||||
impl()->setNumberofUDPInterfaces(numInterfaces) == FAIL) {
|
||||
throw RuntimeError("Failed to set number of interfaces");
|
||||
}
|
||||
return socket.sendResult(ret, retvals, sizeof(retvals), mess);
|
||||
@ -636,7 +643,8 @@ int slsReceiverTCPIPInterface::set_timer(Interface &socket) {
|
||||
int64_t retval = -1;
|
||||
socket.receiveArg(index);
|
||||
if (index[1] >= 0) {
|
||||
FILE_LOG(logDEBUG1) << "Setting timer index " << index[0] << " to " << index[1];
|
||||
FILE_LOG(logDEBUG1)
|
||||
<< "Setting timer index " << index[0] << " to " << index[1];
|
||||
switch (index[0]) {
|
||||
case ACQUISITION_TIME:
|
||||
ret = impl()->setAcquisitionTime(index[1]);
|
||||
@ -657,14 +665,16 @@ int slsReceiverTCPIPInterface::set_timer(Interface &socket) {
|
||||
break;
|
||||
case ANALOG_SAMPLES:
|
||||
if (myDetectorType != CHIPTESTBOARD && myDetectorType != MOENCH) {
|
||||
modeNotImplemented("(Analog Samples) Timer index", (int)index[0]);
|
||||
modeNotImplemented("(Analog Samples) Timer index",
|
||||
(int)index[0]);
|
||||
break;
|
||||
}
|
||||
impl()->setNumberofAnalogSamples(index[1]);
|
||||
break;
|
||||
case DIGITAL_SAMPLES:
|
||||
if (myDetectorType != CHIPTESTBOARD && myDetectorType != MOENCH) {
|
||||
modeNotImplemented("(Digital Samples) Timer index", (int)index[0]);
|
||||
modeNotImplemented("(Digital Samples) Timer index",
|
||||
(int)index[0]);
|
||||
break;
|
||||
}
|
||||
impl()->setNumberofDigitalSamples(index[1]);
|
||||
@ -673,7 +683,6 @@ int slsReceiverTCPIPInterface::set_timer(Interface &socket) {
|
||||
modeNotImplemented("Timer index", (int)index[0]);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
// get
|
||||
switch (index[0]) {
|
||||
@ -696,14 +705,20 @@ int slsReceiverTCPIPInterface::set_timer(Interface &socket) {
|
||||
break;
|
||||
case ANALOG_SAMPLES:
|
||||
if (myDetectorType != CHIPTESTBOARD && myDetectorType != MOENCH) {
|
||||
sprintf(mess,"This timer mode (%lld) does not exist for this receiver type\n", (long long int)index[0]);
|
||||
sprintf(mess,
|
||||
"This timer mode (%lld) does not exist for this receiver "
|
||||
"type\n",
|
||||
(long long int)index[0]);
|
||||
throw RuntimeError(mess);
|
||||
}
|
||||
retval = impl()->getNumberofAnalogSamples();
|
||||
break;
|
||||
case DIGITAL_SAMPLES:
|
||||
if (myDetectorType != CHIPTESTBOARD && myDetectorType != MOENCH) {
|
||||
sprintf(mess,"This timer mode (%lld) does not exist for this receiver type\n", (long long int)index[0]);
|
||||
sprintf(mess,
|
||||
"This timer mode (%lld) does not exist for this receiver "
|
||||
"type\n",
|
||||
(long long int)index[0]);
|
||||
throw RuntimeError(mess);
|
||||
}
|
||||
retval = impl()->getNumberofDigitalSamples();
|
||||
@ -713,7 +728,8 @@ int slsReceiverTCPIPInterface::set_timer(Interface &socket) {
|
||||
break;
|
||||
}
|
||||
validate((int)index[1], (int)retval, std::string("set timer"), DEC);
|
||||
FILE_LOG(logDEBUG1) << slsDetectorDefs::getTimerType((timerIndex)(index[0])) << ":" << retval;
|
||||
FILE_LOG(logDEBUG1) << slsDetectorDefs::getTimerType((timerIndex)(index[0]))
|
||||
<< ":" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@ -738,14 +754,13 @@ int slsReceiverTCPIPInterface::set_dynamic_range(Interface &socket) {
|
||||
}
|
||||
if (!exists) {
|
||||
modeNotImplemented("Dynamic range", dr);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ret = impl()->setDynamicRange(dr);
|
||||
if (ret == FAIL) {
|
||||
throw RuntimeError("Could not allocate memory for fifo or could not start listening/writing threads");
|
||||
throw RuntimeError("Could not allocate memory for fifo or "
|
||||
"could not start listening/writing threads");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
int retval = impl()->getDynamicRange();
|
||||
validate(dr, retval, std::string("set dynamic range"), DEC);
|
||||
@ -777,7 +792,8 @@ int slsReceiverTCPIPInterface::get_status(Interface &socket){
|
||||
int slsReceiverTCPIPInterface::start_receiver(Interface &socket) {
|
||||
runStatus status = impl()->getStatus();
|
||||
if (status != IDLE) {
|
||||
throw RuntimeError("Cannot start Receiver as it is: " +runStatusType(status));
|
||||
throw RuntimeError("Cannot start Receiver as it is: " +
|
||||
runStatusType(status));
|
||||
} else {
|
||||
FILE_LOG(logDEBUG1) << "Starting Receiver";
|
||||
ret = impl()->startReceiver(mess);
|
||||
@ -795,7 +811,8 @@ int slsReceiverTCPIPInterface::stop_receiver(Interface &socket){
|
||||
}
|
||||
auto s = impl()->getStatus();
|
||||
if (s != IDLE)
|
||||
throw RuntimeError("Could not stop receiver. It as it is: " + runStatusType(s));
|
||||
throw RuntimeError("Could not stop receiver. It as it is: " +
|
||||
runStatusType(s));
|
||||
|
||||
return socket.sendData(OK);
|
||||
}
|
||||
@ -880,7 +897,6 @@ int slsReceiverTCPIPInterface::enable_file_write(Interface &socket){
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::enable_master_file_write(Interface &socket) {
|
||||
auto enable = socket.receive<int>();
|
||||
if (enable >= 0) {
|
||||
@ -894,7 +910,6 @@ int slsReceiverTCPIPInterface::enable_master_file_write(Interface &socket){
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::enable_overwrite(Interface &socket) {
|
||||
auto index = socket.receive<int>();
|
||||
if (index >= 0) {
|
||||
@ -910,14 +925,14 @@ int slsReceiverTCPIPInterface::enable_overwrite(Interface &socket) {
|
||||
|
||||
int slsReceiverTCPIPInterface::enable_tengiga(Interface &socket) {
|
||||
auto val = socket.receive<int>();
|
||||
if (myDetectorType != EIGER && myDetectorType != CHIPTESTBOARD && myDetectorType != MOENCH)
|
||||
if (myDetectorType != EIGER && myDetectorType != CHIPTESTBOARD &&
|
||||
myDetectorType != MOENCH)
|
||||
functionNotImplemented();
|
||||
|
||||
if (val >= 0) {
|
||||
VerifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting 10GbE:" << val;
|
||||
ret = impl()->setTenGigaEnable(val);
|
||||
|
||||
}
|
||||
int retval = impl()->getTenGigaEnable();
|
||||
validate(val, retval, std::string("set 10GbE"), DEC);
|
||||
@ -967,8 +982,6 @@ int slsReceiverTCPIPInterface::set_data_stream_enable(Interface &socket){
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::set_streaming_timer(Interface &socket) {
|
||||
auto index = socket.receive<int>();
|
||||
if (index >= 0) {
|
||||
@ -982,8 +995,6 @@ int slsReceiverTCPIPInterface::set_streaming_timer(Interface &socket){
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::set_flipped_data(Interface &socket) {
|
||||
// TODO! Why 2 args?
|
||||
memset(mess, 0, sizeof(mess));
|
||||
@ -1004,8 +1015,6 @@ int slsReceiverTCPIPInterface::set_flipped_data(Interface &socket){
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::set_file_format(Interface &socket) {
|
||||
fileFormat f = GET_FILE_FORMAT;
|
||||
socket.receiveArg(f);
|
||||
@ -1038,9 +1047,9 @@ int slsReceiverTCPIPInterface::set_multi_detector_size(Interface &socket) {
|
||||
socket.receiveArg(arg);
|
||||
if ((arg[0] > 0) && (arg[1] > 0)) {
|
||||
VerifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting multi detector size:" << arg[0] << "," << arg[1];
|
||||
FILE_LOG(logDEBUG1)
|
||||
<< "Setting multi detector size:" << arg[0] << "," << arg[1];
|
||||
impl()->setMultiDetectorSize(arg);
|
||||
|
||||
}
|
||||
int *temp = impl()->getMultiDetectorSize(); // TODO! return by value!
|
||||
int retval = temp[0] * temp[1];
|
||||
@ -1105,7 +1114,8 @@ int slsReceiverTCPIPInterface::enable_gap_pixels(Interface &socket) {
|
||||
int slsReceiverTCPIPInterface::restream_stop(Interface &socket) {
|
||||
VerifyIdle(socket);
|
||||
if (impl()->getDataStreamEnable() == false) {
|
||||
throw RuntimeError("Could not restream stop packet as data Streaming is disabled");
|
||||
throw RuntimeError(
|
||||
"Could not restream stop packet as data Streaming is disabled");
|
||||
} else {
|
||||
FILE_LOG(logDEBUG1) << "Restreaming stop";
|
||||
ret = impl()->restreamStop();
|
||||
@ -1141,17 +1151,23 @@ int slsReceiverTCPIPInterface::set_udp_socket_buffer_size(Interface &socket) {
|
||||
VerifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting UDP Socket Buffer size: " << index;
|
||||
if (impl()->setUDPSocketBufferSize(index) == FAIL) {
|
||||
throw RuntimeError("Could not create dummy UDP Socket to test buffer size");
|
||||
throw RuntimeError(
|
||||
"Could not create dummy UDP Socket to test buffer size");
|
||||
}
|
||||
}
|
||||
int64_t retval = impl()->getUDPSocketBufferSize();
|
||||
if (index != 0)
|
||||
validate(index, retval, std::string("set udp socket buffer size (No CAP_NET_ADMIN privileges?)"), DEC);
|
||||
validate(
|
||||
index, retval,
|
||||
std::string(
|
||||
"set udp socket buffer size (No CAP_NET_ADMIN privileges?)"),
|
||||
DEC);
|
||||
FILE_LOG(logDEBUG1) << "UDP Socket Buffer Size:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
int slsReceiverTCPIPInterface::get_real_udp_socket_buffer_size(Interface &socket){
|
||||
int slsReceiverTCPIPInterface::get_real_udp_socket_buffer_size(
|
||||
Interface &socket) {
|
||||
auto size = impl()->getActualUDPSocketBufferSize();
|
||||
FILE_LOG(logDEBUG1) << "Actual UDP socket size :" << size;
|
||||
return socket.sendResult(size);
|
||||
@ -1172,7 +1188,8 @@ int slsReceiverTCPIPInterface::set_frames_per_file(Interface &socket) {
|
||||
|
||||
int slsReceiverTCPIPInterface::check_version_compatibility(Interface &socket) {
|
||||
auto arg = socket.receive<int64_t>();
|
||||
FILE_LOG(logDEBUG1) << "Checking versioning compatibility with value " << arg;
|
||||
FILE_LOG(logDEBUG1) << "Checking versioning compatibility with value "
|
||||
<< arg;
|
||||
int64_t client_requiredVersion = arg;
|
||||
int64_t rx_apiVersion = APIRECEIVER;
|
||||
int64_t rx_version = getReceiverVersion();
|
||||
@ -1180,8 +1197,10 @@ int slsReceiverTCPIPInterface::check_version_compatibility(Interface &socket) {
|
||||
if (rx_apiVersion > client_requiredVersion) {
|
||||
// old client
|
||||
ret = FAIL;
|
||||
sprintf(mess,"This client is incompatible.\n"
|
||||
"Client's receiver API Version: (0x%llx). Receiver API Version: (0x%llx).\n"
|
||||
sprintf(mess,
|
||||
"This client is incompatible.\n"
|
||||
"Client's receiver API Version: (0x%llx). Receiver API "
|
||||
"Version: (0x%llx).\n"
|
||||
"Incompatible, update client!\n",
|
||||
(long long unsigned int)client_requiredVersion,
|
||||
(long long unsigned int)rx_apiVersion);
|
||||
@ -1189,14 +1208,15 @@ int slsReceiverTCPIPInterface::check_version_compatibility(Interface &socket) {
|
||||
} else if (client_requiredVersion > rx_version) {
|
||||
// old software
|
||||
ret = FAIL;
|
||||
sprintf(mess,"This receiver is incompatible.\n"
|
||||
"Receiver Version: (0x%llx). Client's receiver API Version: (0x%llx).\n"
|
||||
sprintf(mess,
|
||||
"This receiver is incompatible.\n"
|
||||
"Receiver Version: (0x%llx). Client's receiver API Version: "
|
||||
"(0x%llx).\n"
|
||||
"Incompatible, update receiver!\n",
|
||||
(long long unsigned int)rx_version,
|
||||
(long long unsigned int)client_requiredVersion);
|
||||
throw RuntimeError(mess);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
FILE_LOG(logINFO) << "Compatibility with Client: Successful";
|
||||
}
|
||||
return socket.sendData(OK);
|
||||
@ -1229,7 +1249,8 @@ int slsReceiverTCPIPInterface::set_padding_enable(Interface &socket) {
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
int slsReceiverTCPIPInterface::set_deactivated_padding_enable(Interface &socket) {
|
||||
int slsReceiverTCPIPInterface::set_deactivated_padding_enable(
|
||||
Interface &socket) {
|
||||
auto enable = socket.receive<int>();
|
||||
if (myDetectorType != EIGER)
|
||||
functionNotImplemented();
|
||||
@ -1240,7 +1261,8 @@ int slsReceiverTCPIPInterface::set_deactivated_padding_enable(Interface &socket)
|
||||
impl()->setDeactivatedPadding(enable > 0 ? true : false);
|
||||
}
|
||||
auto retval = static_cast<int>(impl()->getDeactivatedPadding());
|
||||
validate(enable, retval, std::string("set deactivated padding enable"), DEC);
|
||||
validate(enable, retval, std::string("set deactivated padding enable"),
|
||||
DEC);
|
||||
FILE_LOG(logDEBUG1) << "Deactivated Padding Enable: " << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
@ -1248,7 +1270,8 @@ int slsReceiverTCPIPInterface::set_deactivated_padding_enable(Interface &socket)
|
||||
int slsReceiverTCPIPInterface::set_readout_flags(Interface &socket) {
|
||||
auto arg = socket.receive<readOutFlags>();
|
||||
|
||||
if (myDetectorType == JUNGFRAU || myDetectorType == GOTTHARD || myDetectorType == MOENCH)
|
||||
if (myDetectorType == JUNGFRAU || myDetectorType == GOTTHARD ||
|
||||
myDetectorType == MOENCH)
|
||||
functionNotImplemented();
|
||||
|
||||
if (arg >= 0) {
|
||||
@ -1257,7 +1280,8 @@ int slsReceiverTCPIPInterface::set_readout_flags(Interface &socket) {
|
||||
ret = impl()->setReadOutFlags(arg);
|
||||
}
|
||||
auto retval = impl()->getReadOutFlags();
|
||||
validate((int)arg, (int)(retval & arg), std::string("set readout flags"), HEX);
|
||||
validate((int)arg, (int)(retval & arg), std::string("set readout flags"),
|
||||
HEX);
|
||||
FILE_LOG(logDEBUG1) << "Readout flags: " << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
@ -1269,7 +1293,8 @@ int slsReceiverTCPIPInterface::set_adc_mask(Interface &socket) {
|
||||
impl()->setADCEnableMask(arg);
|
||||
auto retval = impl()->getADCEnableMask();
|
||||
if (retval != arg) {
|
||||
sprintf(mess, "Could not ADC enable mask. Set 0x%x, but read 0x%x\n", arg, retval);
|
||||
sprintf(mess, "Could not ADC enable mask. Set 0x%x, but read 0x%x\n",
|
||||
arg, retval);
|
||||
throw RuntimeError(mess);
|
||||
}
|
||||
FILE_LOG(logDEBUG1) << "ADC enable mask retval: " << retval;
|
||||
|
Loading…
x
Reference in New Issue
Block a user