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 {
|
||||
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 *******
|
||||
@ -47,7 +48,7 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
* Get multi detector size
|
||||
* @return pointer to array of multi detector size in every dimension
|
||||
*/
|
||||
int* getMultiDetectorSize() const;
|
||||
int *getMultiDetectorSize() const;
|
||||
|
||||
/*
|
||||
* Get detector position id
|
||||
@ -65,7 +66,7 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
* Get flipped data across 'axis'
|
||||
* @return if data is flipped across 'axis'
|
||||
*/
|
||||
int getFlippedData(int axis=0) const;
|
||||
int getFlippedData(int axis = 0) const;
|
||||
|
||||
/**
|
||||
* Get Gap Pixels Enable (eiger specific)
|
||||
@ -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;
|
||||
|
||||
@ -304,7 +305,7 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
* Get CTB digital bits enable list
|
||||
* @returns digital bits enable list
|
||||
*/
|
||||
std::vector <int> getDbitList() const;
|
||||
std::vector<int> getDbitList() const;
|
||||
|
||||
/**
|
||||
* Get CTB digital bits offset
|
||||
@ -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
|
||||
@ -375,13 +375,13 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
* Set multi detector size
|
||||
* @param pointer to array of multi detector size in every dimension
|
||||
*/
|
||||
void setMultiDetectorSize(const int* size);
|
||||
void setMultiDetectorSize(const int *size);
|
||||
|
||||
/*
|
||||
* Get flipped data across 'axis'
|
||||
* @return if data is flipped across 'axis'
|
||||
*/
|
||||
void setFlippedData(int axis=0, int enable=-1);
|
||||
void setFlippedData(int axis = 0, int enable = -1);
|
||||
|
||||
/**
|
||||
* Set Gap Pixels Enable (eiger specific)
|
||||
@ -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[]);
|
||||
@ -479,13 +479,13 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
* Set Ethernet Interface to listen to
|
||||
* @param c ethernet inerface eg. eth0 (max of 1000 characters)
|
||||
*/
|
||||
void setEthernetInterface(const char* c);
|
||||
void setEthernetInterface(const char *c);
|
||||
|
||||
/**
|
||||
* Set second Ethernet Interface to listen to (jungfrau specific)
|
||||
* @param c second ethernet inerface eg. eth0 (max of 1000 characters)
|
||||
*/
|
||||
void setEthernetInterface2(const char* c);
|
||||
void setEthernetInterface2(const char *c);
|
||||
|
||||
/**
|
||||
* Set number of UDP Interfaces (jungfrau specific)
|
||||
@ -501,7 +501,6 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
*/
|
||||
int setUDPSocketBufferSize(const int64_t s);
|
||||
|
||||
|
||||
//***acquisition parameters***
|
||||
/**
|
||||
* Set ROI
|
||||
@ -551,7 +550,7 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
/**
|
||||
* Set additional json header
|
||||
*/
|
||||
void setAdditionalJsonHeader(const char* c);
|
||||
void setAdditionalJsonHeader(const char *c);
|
||||
|
||||
/**
|
||||
* Set Acquisition Period
|
||||
@ -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
|
||||
*/
|
||||
@ -653,7 +652,7 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
* Set CTB digital bits enable list
|
||||
* @param v digital bits enable list
|
||||
*/
|
||||
void setDbitList(const std::vector <int> v);
|
||||
void setDbitList(const std::vector<int> v);
|
||||
|
||||
/**
|
||||
* Set CTB digital bits offset
|
||||
@ -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,34 +683,37 @@ 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
|
||||
*/
|
||||
int startReceiver(char *c=NULL);
|
||||
int startReceiver(char *c = NULL);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
private:
|
||||
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 *********************************************************
|
||||
*************************************************************************/
|
||||
@ -888,7 +893,7 @@ private:
|
||||
/** silent mode */
|
||||
bool silentMode;
|
||||
/** ctb digital bits enabled list (empty: all enabled) */
|
||||
std::vector <int> ctbDbitList;
|
||||
std::vector<int> ctbDbitList;
|
||||
/** ctb digital bit offset in bytes */
|
||||
int ctbDbitOffset;
|
||||
/* analog data bytes */
|
||||
@ -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];
|
||||
@ -944,7 +950,7 @@ private:
|
||||
|
||||
//** class objects ***
|
||||
/** General Data Properties */
|
||||
GeneralData* generalData;
|
||||
GeneralData *generalData;
|
||||
/** Listener Objects that listen to UDP and push into fifo */
|
||||
std::vector<std::unique_ptr<Listener>> listener;
|
||||
/** DataProcessor Objects that pull from fifo and process data */
|
||||
@ -967,14 +973,14 @@ private:
|
||||
* 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*);
|
||||
int (*startAcquisitionCallBack)(char *, char *, uint64_t, uint32_t, void *);
|
||||
void *pStartAcquisition;
|
||||
/**
|
||||
* Call back for acquisition finished
|
||||
* callback argument is
|
||||
* total frames caught
|
||||
*/
|
||||
void (*acquisitionFinishedCallBack)(uint64_t, void*);
|
||||
void (*acquisitionFinishedCallBack)(uint64_t, void *);
|
||||
void *pAcquisitionFinished;
|
||||
/**
|
||||
* Call back for raw data
|
||||
@ -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
|
||||
@ -20,10 +20,9 @@ class ServerInterface;
|
||||
|
||||
class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
||||
private:
|
||||
enum numberMode {DEC, HEX};
|
||||
enum numberMode { DEC, HEX };
|
||||
|
||||
public:
|
||||
|
||||
/** Destructor */
|
||||
virtual ~slsReceiverTCPIPInterface();
|
||||
|
||||
@ -34,7 +33,7 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
||||
* @param pn port number (defaults to default port number)
|
||||
*/
|
||||
|
||||
slsReceiverTCPIPInterface(int pn=-1);
|
||||
slsReceiverTCPIPInterface(int pn = -1);
|
||||
|
||||
/**
|
||||
* Starts listening on the TCP port for client comminication
|
||||
@ -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,21 +89,20 @@ 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()
|
||||
* @param this_pointer pointer to this object
|
||||
*/
|
||||
static void* startTCPServerThread(void *this_pointer);
|
||||
|
||||
static void *startTCPServerThread(void *this_pointer);
|
||||
|
||||
/**
|
||||
* Thread started which is a TCP server
|
||||
@ -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};
|
||||
|
||||
/**
|
||||
@ -347,10 +350,9 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
||||
* callback argument is
|
||||
* total frames caught
|
||||
*/
|
||||
void (*acquisitionFinishedCallBack)(uint64_t, void*) = nullptr;
|
||||
void (*acquisitionFinishedCallBack)(uint64_t, void *) = nullptr;
|
||||
void *pAcquisitionFinished{nullptr};
|
||||
|
||||
|
||||
/**
|
||||
* Call back for raw data
|
||||
* args to raw data ready callback are
|
||||
@ -358,37 +360,34 @@ 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:
|
||||
|
||||
|
||||
protected:
|
||||
std::unique_ptr<sls::ServerSocket> server{nullptr};
|
||||
|
||||
private:
|
||||
void VerifyLock();
|
||||
void VerifyIdle(sls::ServerInterface2& socket);
|
||||
void VerifyIdle(sls::ServerInterface2 &socket);
|
||||
|
||||
slsReceiverImplementation* impl(){
|
||||
if (receiver!=nullptr){
|
||||
slsReceiverImplementation *impl() {
|
||||
if (receiver != nullptr) {
|
||||
return receiver.get();
|
||||
}else{
|
||||
throw sls::SocketError("Receiver not set up. Please use rx_hostname first.\n");
|
||||
} else {
|
||||
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(){
|
||||
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,58 +49,56 @@ int slsReceiverTCPIPInterface::start(){
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
void slsReceiverTCPIPInterface::stop(){
|
||||
void slsReceiverTCPIPInterface::stop() {
|
||||
if (tcpThreadCreated) {
|
||||
FILE_LOG(logINFO) << "Shutting down TCP Socket on port " << portNumber;
|
||||
killTCPServerThread = 1;
|
||||
if(server)
|
||||
if (server)
|
||||
server->shutDownSocket();
|
||||
FILE_LOG(logDEBUG) << "TCP Socket closed on port " << portNumber;
|
||||
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){
|
||||
startAcquisitionCallBack=func;
|
||||
pStartAcquisition=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){
|
||||
acquisitionFinishedCallBack=func;
|
||||
pAcquisitionFinished=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){
|
||||
rawDataReadyCallBack=func;
|
||||
pRawDataReady=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){
|
||||
rawDataModifyReadyCallBack=func;
|
||||
pRawDataReady=arg;
|
||||
void slsReceiverTCPIPInterface::registerCallBackRawDataModifyReady(
|
||||
void (*func)(char *, char *, uint32_t &, void *), void *arg) {
|
||||
rawDataModifyReadyCallBack = func;
|
||||
pRawDataReady = arg;
|
||||
}
|
||||
|
||||
void* slsReceiverTCPIPInterface::startTCPServerThread(void *this_pointer){
|
||||
((slsReceiverTCPIPInterface*)this_pointer)->startTCPServer();
|
||||
void *slsReceiverTCPIPInterface::startTCPServerThread(void *this_pointer) {
|
||||
((slsReceiverTCPIPInterface *)this_pointer)->startTCPServer();
|
||||
return 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);
|
||||
@ -111,18 +106,17 @@ void slsReceiverTCPIPInterface::startTCPServer() {
|
||||
FILE_LOG(logDEBUG1) << "Start accept loop";
|
||||
try {
|
||||
auto socket = server->accept();
|
||||
try{
|
||||
try {
|
||||
VerifyLock();
|
||||
ret = decode_function(socket);
|
||||
}catch(const RuntimeError& e){
|
||||
//We had an error needs to be sent to client
|
||||
} catch (const RuntimeError &e) {
|
||||
// We had an error needs to be sent to client
|
||||
int r = FAIL;
|
||||
strcpy(mess, e.what());
|
||||
socket.write(&r, sizeof(r));
|
||||
socket.write(mess, sizeof(mess));
|
||||
}
|
||||
|
||||
|
||||
// if tcp command was to exit server
|
||||
if (ret == GOODBYE) {
|
||||
FILE_LOG(logINFO) << "Shutting down UDP Socket";
|
||||
@ -134,7 +128,7 @@ void slsReceiverTCPIPInterface::startTCPServer() {
|
||||
<< "]";
|
||||
pthread_exit(nullptr);
|
||||
}
|
||||
}catch(const RuntimeError& e){
|
||||
} catch (const RuntimeError &e) {
|
||||
std::cout << "Accept failed\n";
|
||||
}
|
||||
|
||||
@ -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,21 +235,24 @@ 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",
|
||||
modename.c_str(), (unsigned int) arg, (unsigned int) retval);
|
||||
modename.c_str(), (unsigned int)arg, (unsigned int)retval);
|
||||
else
|
||||
sprintf(mess, "Could not %s. Set %d, but read %d\n",
|
||||
modename.c_str(), (unsigned int) arg, (unsigned int) retval);
|
||||
modename.c_str(), (unsigned int)arg, (unsigned int)retval);
|
||||
throw RuntimeError(mess);
|
||||
}
|
||||
}
|
||||
@ -310,7 +307,7 @@ int slsReceiverTCPIPInterface::lock_receiver(Interface &socket) {
|
||||
lockStatus = lock;
|
||||
lock ? server->setLockedBy(server->getThisClient())
|
||||
: server->setLockedBy(sls::IpAddr{});
|
||||
} else{
|
||||
} else {
|
||||
throw RuntimeError("Receiver locked\n");
|
||||
}
|
||||
}
|
||||
@ -325,13 +322,13 @@ 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;
|
||||
FILE_LOG(logINFO) << "set port to " << p_number << std::endl;
|
||||
auto new_server = sls::make_unique<sls::ServerSocket>(p_number);
|
||||
new_server->setLockedBy(server->getLockedBy());
|
||||
new_server->setLastClient(server->getThisClient());
|
||||
@ -341,14 +338,13 @@ 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");
|
||||
if (receiver == nullptr)
|
||||
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;
|
||||
@ -356,7 +352,7 @@ int slsReceiverTCPIPInterface::send_update(Interface &socket) {
|
||||
|
||||
char ip[INET_ADDRSTRLEN]{};
|
||||
sls::strcpy_safe(ip, server->getLastClient().str().c_str());
|
||||
n += socket.sendData(ip,sizeof(ip));
|
||||
n += socket.sendData(ip, sizeof(ip));
|
||||
|
||||
// filepath
|
||||
strcpy(cstring, receiver->getFilePath().c_str());
|
||||
@ -367,47 +363,47 @@ int slsReceiverTCPIPInterface::send_update(Interface &socket) {
|
||||
n += socket.sendData(cstring, sizeof(cstring));
|
||||
|
||||
// index
|
||||
i32=receiver->getFileIndex();
|
||||
i32 = receiver->getFileIndex();
|
||||
n += socket.sendData(&i32, sizeof(i32));
|
||||
|
||||
//file format
|
||||
i32=(int)receiver->getFileFormat();
|
||||
// file format
|
||||
i32 = (int)receiver->getFileFormat();
|
||||
n += socket.sendData(&i32, sizeof(i32));
|
||||
|
||||
//frames per file
|
||||
i32=(int)receiver->getFramesPerFile();
|
||||
// frames per file
|
||||
i32 = (int)receiver->getFramesPerFile();
|
||||
n += socket.sendData(&i32, sizeof(i32));
|
||||
|
||||
//frame discard policy
|
||||
i32=(int)receiver->getFrameDiscardPolicy();
|
||||
// frame discard policy
|
||||
i32 = (int)receiver->getFrameDiscardPolicy();
|
||||
n += socket.sendData(&i32, sizeof(i32));
|
||||
|
||||
//frame padding
|
||||
i32=(int)receiver->getFramePaddingEnable();
|
||||
// frame padding
|
||||
i32 = (int)receiver->getFramePaddingEnable();
|
||||
n += socket.sendData(&i32, sizeof(i32));
|
||||
|
||||
// file write enable
|
||||
i32=(int)receiver->getFileWriteEnable();
|
||||
i32 = (int)receiver->getFileWriteEnable();
|
||||
n += socket.sendData(&i32, sizeof(i32));
|
||||
|
||||
// master file write enable
|
||||
i32=(int)receiver->getMasterFileWriteEnable();
|
||||
i32 = (int)receiver->getMasterFileWriteEnable();
|
||||
n += socket.sendData(&i32, sizeof(i32));
|
||||
|
||||
// file overwrite enable
|
||||
i32=(int)receiver->getOverwriteEnable();
|
||||
i32 = (int)receiver->getOverwriteEnable();
|
||||
n += socket.sendData(&i32, sizeof(i32));
|
||||
|
||||
// gap pixels
|
||||
i32=(int)receiver->getGapPixelsEnable();
|
||||
i32 = (int)receiver->getGapPixelsEnable();
|
||||
n += socket.sendData(&i32, sizeof(i32));
|
||||
|
||||
// streaming frequency
|
||||
i32=(int)receiver->getStreamingFrequency();
|
||||
i32 = (int)receiver->getStreamingFrequency();
|
||||
n += socket.sendData(&i32, sizeof(i32));
|
||||
|
||||
// streaming port
|
||||
i32=(int)receiver->getStreamingPort();
|
||||
i32 = (int)receiver->getStreamingPort();
|
||||
n += socket.sendData(&i32, sizeof(i32));
|
||||
|
||||
// streaming source ip
|
||||
@ -419,24 +415,24 @@ int slsReceiverTCPIPInterface::send_update(Interface &socket) {
|
||||
n += socket.sendData(cstring, sizeof(cstring));
|
||||
|
||||
// data streaming enable
|
||||
i32=(int)receiver->getDataStreamEnable();
|
||||
i32 = (int)receiver->getDataStreamEnable();
|
||||
n += socket.sendData(&i32, sizeof(i32));
|
||||
|
||||
// activate
|
||||
i32=(int)receiver->getActivate();
|
||||
i32 = (int)receiver->getActivate();
|
||||
n += socket.sendData(&i32, sizeof(i32));
|
||||
|
||||
// deactivated padding enable
|
||||
i32=(int)receiver->getDeactivatedPadding();
|
||||
i32 = (int)receiver->getDeactivatedPadding();
|
||||
n += socket.sendData(&i32, sizeof(i32));
|
||||
|
||||
// silent mode
|
||||
i32=(int)receiver->getSilentMode();
|
||||
i32 = (int)receiver->getSilentMode();
|
||||
n += socket.sendData(&i32, sizeof(i32));
|
||||
|
||||
// dbit list
|
||||
{
|
||||
std::vector <int> list = receiver->getDbitList();
|
||||
std::vector<int> list = receiver->getDbitList();
|
||||
int retvalsize = list.size();
|
||||
int retval[retvalsize];
|
||||
std::copy(std::begin(list), std::end(list), retval);
|
||||
@ -445,25 +441,26 @@ int slsReceiverTCPIPInterface::send_update(Interface &socket) {
|
||||
}
|
||||
|
||||
// dbit offset
|
||||
i32=receiver->getDbitOffset();
|
||||
i32 = receiver->getDbitOffset();
|
||||
n += socket.sendData(&i32, sizeof(i32));
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int slsReceiverTCPIPInterface::get_id(Interface &socket){
|
||||
int slsReceiverTCPIPInterface::get_id(Interface &socket) {
|
||||
return socket.sendResult(getReceiverVersion());
|
||||
}
|
||||
|
||||
int slsReceiverTCPIPInterface::set_detector_type(Interface &socket){
|
||||
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 (receiver != nullptr){
|
||||
// if object exists, verify unlocked and idle, else only verify lock
|
||||
// (connecting first time)
|
||||
if (receiver != nullptr) {
|
||||
VerifyIdle(socket);
|
||||
}
|
||||
switch(arg) {
|
||||
switch (arg) {
|
||||
case GOTTHARD:
|
||||
case EIGER:
|
||||
case CHIPTESTBOARD:
|
||||
@ -475,24 +472,27 @@ int slsReceiverTCPIPInterface::set_detector_type(Interface &socket){
|
||||
break;
|
||||
}
|
||||
|
||||
if(receiver == nullptr){
|
||||
if (receiver == nullptr) {
|
||||
receiver = sls::make_unique<slsReceiverImplementation>();
|
||||
}
|
||||
myDetectorType = arg;
|
||||
if (impl()->setDetectorType(myDetectorType) == FAIL){
|
||||
if (impl()->setDetectorType(myDetectorType) == FAIL) {
|
||||
throw RuntimeError("Could not set detector type");
|
||||
}
|
||||
|
||||
// callbacks after (in setdetectortype, the object is reinitialized)
|
||||
if(startAcquisitionCallBack)
|
||||
impl()->registerCallBackStartAcquisition(startAcquisitionCallBack,pStartAcquisition);
|
||||
if(acquisitionFinishedCallBack)
|
||||
impl()->registerCallBackAcquisitionFinished(acquisitionFinishedCallBack,pAcquisitionFinished);
|
||||
if(rawDataReadyCallBack)
|
||||
impl()->registerCallBackRawDataReady(rawDataReadyCallBack,pRawDataReady);
|
||||
if(rawDataModifyReadyCallBack)
|
||||
impl()->registerCallBackRawDataModifyReady(rawDataModifyReadyCallBack,pRawDataReady);
|
||||
|
||||
if (startAcquisitionCallBack)
|
||||
impl()->registerCallBackStartAcquisition(startAcquisitionCallBack,
|
||||
pStartAcquisition);
|
||||
if (acquisitionFinishedCallBack)
|
||||
impl()->registerCallBackAcquisitionFinished(
|
||||
acquisitionFinishedCallBack, pAcquisitionFinished);
|
||||
if (rawDataReadyCallBack)
|
||||
impl()->registerCallBackRawDataReady(rawDataReadyCallBack,
|
||||
pRawDataReady);
|
||||
if (rawDataModifyReadyCallBack)
|
||||
impl()->registerCallBackRawDataModifyReady(
|
||||
rawDataModifyReadyCallBack, pRawDataReady);
|
||||
}
|
||||
return socket.sendResult(myDetectorType);
|
||||
}
|
||||
@ -514,11 +514,10 @@ 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");
|
||||
static_assert(sizeof(ROI) == 4 * sizeof(int), "ROI not packed");
|
||||
auto narg = socket.receive<int>();
|
||||
std::vector <ROI> arg;
|
||||
std::vector<ROI> arg;
|
||||
for (int iloop = 0; iloop < narg; ++iloop) {
|
||||
ROI temp{};
|
||||
socket.receiveArg(temp);
|
||||
@ -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)
|
||||
@ -540,17 +539,17 @@ int slsReceiverTCPIPInterface::set_roi(Interface &socket) {
|
||||
return socket.sendData(OK);
|
||||
}
|
||||
|
||||
int slsReceiverTCPIPInterface::setup_udp(Interface &socket){
|
||||
int slsReceiverTCPIPInterface::setup_udp(Interface &socket) {
|
||||
ret = OK;
|
||||
char args[5][MAX_STR_LENGTH]{};
|
||||
char retvals[2][MAX_STR_LENGTH]{};
|
||||
socket.receiveArg(args);
|
||||
VerifyIdle(socket);
|
||||
|
||||
//setup interfaces count
|
||||
// setup interfaces count
|
||||
int numInterfaces = atoi(args[0]) > 1 ? 2 : 1;
|
||||
char* ip1 = args[1];
|
||||
char* ip2 = args[2];
|
||||
char *ip1 = args[1];
|
||||
char *ip2 = args[2];
|
||||
uint32_t port1 = atoi(args[3]);
|
||||
uint32_t port2 = atoi(args[4]);
|
||||
|
||||
@ -562,7 +561,7 @@ int slsReceiverTCPIPInterface::setup_udp(Interface &socket){
|
||||
FILE_LOG(logINFO) << "Receiver UDP IP: " << ip1;
|
||||
// get eth
|
||||
std::string temp = sls::IpToInterfaceName(ip1);
|
||||
if (temp == "none"){
|
||||
if (temp == "none") {
|
||||
throw RuntimeError("Failed to get ethernet interface or IP");
|
||||
} else {
|
||||
char eth[MAX_STR_LENGTH]{};
|
||||
@ -570,20 +569,21 @@ 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);
|
||||
if (myDetectorType == EIGER) {
|
||||
impl()->setEthernetInterface2(eth);
|
||||
}
|
||||
//get mac address
|
||||
// get mac address
|
||||
if (ret != FAIL) {
|
||||
temp = sls::InterfaceNameToMac(eth).str();
|
||||
if (temp=="00:00:00:00:00:00") {
|
||||
if (temp == "00:00:00:00:00:00") {
|
||||
throw RuntimeError("failed to get mac adddress to listen to\n");
|
||||
} else {
|
||||
strcpy(retvals[0],temp.c_str());
|
||||
strcpy(retvals[0], temp.c_str());
|
||||
FILE_LOG(logINFO) << "Receiver MAC Address: " << retvals[0];
|
||||
}
|
||||
}
|
||||
@ -595,7 +595,7 @@ int slsReceiverTCPIPInterface::setup_udp(Interface &socket){
|
||||
FILE_LOG(logINFO) << "Receiver UDP IP 2: " << ip2;
|
||||
// get eth
|
||||
temp = sls::IpToInterfaceName(ip2);
|
||||
if (temp == "none"){
|
||||
if (temp == "none") {
|
||||
throw RuntimeError("Failed to get 2nd ethernet interface or IP");
|
||||
} else {
|
||||
char eth[MAX_STR_LENGTH] = {""};
|
||||
@ -604,27 +604,34 @@ 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);
|
||||
|
||||
//get mac address
|
||||
// get mac address
|
||||
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");
|
||||
if (temp == "00:00:00:00:00:00") {
|
||||
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];
|
||||
strcpy(retvals[1], temp.c_str());
|
||||
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,47 +683,53 @@ int slsReceiverTCPIPInterface::set_timer(Interface &socket) {
|
||||
modeNotImplemented("Timer index", (int)index[0]);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
// get
|
||||
switch (index[0]) {
|
||||
case ACQUISITION_TIME:
|
||||
retval=impl()->getAcquisitionTime();
|
||||
retval = impl()->getAcquisitionTime();
|
||||
break;
|
||||
case FRAME_PERIOD:
|
||||
retval=impl()->getAcquisitionPeriod();
|
||||
retval = impl()->getAcquisitionPeriod();
|
||||
break;
|
||||
case FRAME_NUMBER:
|
||||
case CYCLES_NUMBER:
|
||||
case STORAGE_CELL_NUMBER:
|
||||
retval=impl()->getNumberOfFrames();
|
||||
retval = impl()->getNumberOfFrames();
|
||||
break;
|
||||
case SUBFRAME_ACQUISITION_TIME:
|
||||
retval=impl()->getSubExpTime();
|
||||
retval = impl()->getSubExpTime();
|
||||
break;
|
||||
case SUBFRAME_DEADTIME:
|
||||
retval=(impl()->getSubPeriod() - impl()->getSubExpTime());
|
||||
retval = (impl()->getSubPeriod() - impl()->getSubExpTime());
|
||||
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();
|
||||
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();
|
||||
retval = impl()->getNumberofDigitalSamples();
|
||||
break;
|
||||
default:
|
||||
modeNotImplemented("Timer index", (int)index[0]);
|
||||
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");
|
||||
if (ret == FAIL) {
|
||||
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);
|
||||
@ -759,7 +774,7 @@ int slsReceiverTCPIPInterface::set_streaming_frequency(Interface &socket) {
|
||||
VerifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting streaming frequency: " << index;
|
||||
ret = impl()->setStreamingFrequency(index);
|
||||
if(ret == FAIL) {
|
||||
if (ret == FAIL) {
|
||||
throw RuntimeError("Could not allocate memory for listening fifo");
|
||||
}
|
||||
}
|
||||
@ -768,17 +783,18 @@ int slsReceiverTCPIPInterface::set_streaming_frequency(Interface &socket) {
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
int slsReceiverTCPIPInterface::get_status(Interface &socket){
|
||||
int slsReceiverTCPIPInterface::get_status(Interface &socket) {
|
||||
auto retval = impl()->getStatus();
|
||||
FILE_LOG(logDEBUG1) << "Status:" << runStatusType(retval);
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
int slsReceiverTCPIPInterface::start_receiver(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));
|
||||
}else {
|
||||
throw RuntimeError("Cannot start Receiver as it is: " +
|
||||
runStatusType(status));
|
||||
} else {
|
||||
FILE_LOG(logDEBUG1) << "Starting Receiver";
|
||||
ret = impl()->startReceiver(mess);
|
||||
if (ret == FAIL) {
|
||||
@ -788,14 +804,15 @@ int slsReceiverTCPIPInterface::start_receiver(Interface &socket){
|
||||
return socket.sendData(OK);
|
||||
}
|
||||
|
||||
int slsReceiverTCPIPInterface::stop_receiver(Interface &socket){
|
||||
if(impl()->getStatus() != IDLE) {
|
||||
int slsReceiverTCPIPInterface::stop_receiver(Interface &socket) {
|
||||
if (impl()->getStatus() != IDLE) {
|
||||
FILE_LOG(logDEBUG1) << "Stopping Receiver";
|
||||
impl()->stopReceiver();
|
||||
}
|
||||
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);
|
||||
}
|
||||
@ -849,25 +866,25 @@ int slsReceiverTCPIPInterface::set_file_index(Interface &socket) {
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
int slsReceiverTCPIPInterface::get_frame_index(Interface &socket){
|
||||
int slsReceiverTCPIPInterface::get_frame_index(Interface &socket) {
|
||||
uint64_t retval = impl()->getAcquisitionIndex();
|
||||
FILE_LOG(logDEBUG1) << "frame index:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
int slsReceiverTCPIPInterface::get_frames_caught(Interface &socket){
|
||||
int slsReceiverTCPIPInterface::get_frames_caught(Interface &socket) {
|
||||
int retval = impl()->getTotalFramesCaught();
|
||||
FILE_LOG(logDEBUG1) << "frames caught:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
int slsReceiverTCPIPInterface::reset_frames_caught(Interface &socket){
|
||||
int slsReceiverTCPIPInterface::reset_frames_caught(Interface &socket) {
|
||||
FILE_LOG(logDEBUG1) << "Reset frames caught";
|
||||
impl()->resetAcquisitionCount();
|
||||
return socket.sendData(OK);
|
||||
}
|
||||
|
||||
int slsReceiverTCPIPInterface::enable_file_write(Interface &socket){
|
||||
int slsReceiverTCPIPInterface::enable_file_write(Interface &socket) {
|
||||
auto enable = socket.receive<int>();
|
||||
if (enable >= 0) {
|
||||
VerifyIdle(socket);
|
||||
@ -880,8 +897,7 @@ int slsReceiverTCPIPInterface::enable_file_write(Interface &socket){
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::enable_master_file_write(Interface &socket){
|
||||
int slsReceiverTCPIPInterface::enable_master_file_write(Interface &socket) {
|
||||
auto enable = socket.receive<int>();
|
||||
if (enable >= 0) {
|
||||
VerifyIdle(socket);
|
||||
@ -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);
|
||||
@ -954,7 +969,7 @@ int slsReceiverTCPIPInterface::set_activate(Interface &socket) {
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
int slsReceiverTCPIPInterface::set_data_stream_enable(Interface &socket){
|
||||
int slsReceiverTCPIPInterface::set_data_stream_enable(Interface &socket) {
|
||||
auto index = socket.receive<int>();
|
||||
if (index >= 0) {
|
||||
VerifyIdle(socket);
|
||||
@ -967,27 +982,23 @@ int slsReceiverTCPIPInterface::set_data_stream_enable(Interface &socket){
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::set_streaming_timer(Interface &socket){
|
||||
int slsReceiverTCPIPInterface::set_streaming_timer(Interface &socket) {
|
||||
auto index = socket.receive<int>();
|
||||
if (index >= 0) {
|
||||
VerifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting streaming timer:" << index;
|
||||
impl()->setStreamingTimer(index);
|
||||
}
|
||||
int retval=impl()->getStreamingTimer();
|
||||
int retval = impl()->getStreamingTimer();
|
||||
validate(index, retval, std::string("set data stream timer"), DEC);
|
||||
FILE_LOG(logDEBUG1) << "Streaming timer:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::set_flipped_data(Interface &socket){
|
||||
//TODO! Why 2 args?
|
||||
int slsReceiverTCPIPInterface::set_flipped_data(Interface &socket) {
|
||||
// TODO! Why 2 args?
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int args[2]{0,-1};
|
||||
int args[2]{0, -1};
|
||||
socket.receiveArg(args);
|
||||
|
||||
if (myDetectorType != EIGER)
|
||||
@ -996,7 +1007,7 @@ int slsReceiverTCPIPInterface::set_flipped_data(Interface &socket){
|
||||
if (args[1] >= 0) {
|
||||
VerifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting flipped data:" << args[1];
|
||||
impl()->setFlippedData(args[0],args[1]);
|
||||
impl()->setFlippedData(args[0], args[1]);
|
||||
}
|
||||
int retval = impl()->getFlippedData(args[0]);
|
||||
validate(args[1], retval, std::string("set flipped data"), DEC);
|
||||
@ -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);
|
||||
@ -1036,14 +1045,14 @@ int slsReceiverTCPIPInterface::set_detector_posid(Interface &socket) {
|
||||
int slsReceiverTCPIPInterface::set_multi_detector_size(Interface &socket) {
|
||||
int arg[]{-1, -1};
|
||||
socket.receiveArg(arg);
|
||||
if((arg[0] > 0) && (arg[1] > 0)) {
|
||||
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];
|
||||
int *temp = impl()->getMultiDetectorSize(); // TODO! return by value!
|
||||
int retval = temp[0] * temp[1];
|
||||
FILE_LOG(logDEBUG1) << "Multi Detector Size:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
@ -1102,10 +1111,11 @@ int slsReceiverTCPIPInterface::enable_gap_pixels(Interface &socket) {
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
int slsReceiverTCPIPInterface::restream_stop(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,23 +1197,26 @@ 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);
|
||||
throw RuntimeError(mess);
|
||||
}else if (client_requiredVersion > rx_version) {
|
||||
} 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