mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-06 18:10: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
|
#pragma once
|
||||||
/********************************************//**
|
/********************************************/ /**
|
||||||
* @file slsReceiverImplementation.h
|
* @file
|
||||||
* @short does all the functions for a receiver, set/get parameters, start/stop etc.
|
*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 "sls_detector_defs.h"
|
||||||
#include "receiver_defs.h"
|
|
||||||
#include "logger.h"
|
|
||||||
#include "container_utils.h"
|
#include "container_utils.h"
|
||||||
|
#include "logger.h"
|
||||||
|
#include "receiver_defs.h"
|
||||||
class GeneralData;
|
class GeneralData;
|
||||||
class Listener;
|
class Listener;
|
||||||
class DataProcessor;
|
class DataProcessor;
|
||||||
@ -18,13 +22,11 @@ class Fifo;
|
|||||||
class slsDetectorDefs;
|
class slsDetectorDefs;
|
||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <vector>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class slsReceiverImplementation: private virtual slsDetectorDefs {
|
class slsReceiverImplementation : private virtual slsDetectorDefs {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
//*** cosntructor & destructor ***
|
//*** cosntructor & destructor ***
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -36,7 +38,6 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
virtual ~slsReceiverImplementation();
|
virtual ~slsReceiverImplementation();
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* Getters ***************************************************************
|
* Getters ***************************************************************
|
||||||
* They access local cache of configuration or detector parameters *******
|
* They access local cache of configuration or detector parameters *******
|
||||||
@ -47,7 +48,7 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
* Get multi detector size
|
* Get multi detector size
|
||||||
* @return pointer to array of multi detector size in every dimension
|
* @return pointer to array of multi detector size in every dimension
|
||||||
*/
|
*/
|
||||||
int* getMultiDetectorSize() const;
|
int *getMultiDetectorSize() const;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get detector position id
|
* Get detector position id
|
||||||
@ -65,7 +66,7 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
* Get flipped data across 'axis'
|
* Get flipped data across 'axis'
|
||||||
* @return if data is flipped 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)
|
* Get Gap Pixels Enable (eiger specific)
|
||||||
@ -79,7 +80,6 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
readOutFlags getReadOutFlags() const;
|
readOutFlags getReadOutFlags() const;
|
||||||
|
|
||||||
|
|
||||||
//***file parameters***
|
//***file parameters***
|
||||||
/**
|
/**
|
||||||
* Get File Format
|
* Get File Format
|
||||||
@ -87,7 +87,8 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
fileFormat getFileFormat() const;
|
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
|
* @return file name prefix
|
||||||
*/
|
*/
|
||||||
std::string getFileName() const;
|
std::string getFileName() const;
|
||||||
@ -140,7 +141,6 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
bool getOverwriteEnable() const;
|
bool getOverwriteEnable() const;
|
||||||
|
|
||||||
|
|
||||||
//***acquisition count parameters***
|
//***acquisition count parameters***
|
||||||
/**
|
/**
|
||||||
* Get Total Frames Caught for an entire acquisition (including all scans)
|
* 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)
|
* 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;
|
uint64_t getAcquisitionIndex() const;
|
||||||
|
|
||||||
|
|
||||||
//***connection parameters***
|
//***connection parameters***
|
||||||
/**
|
/**
|
||||||
* Get UDP Port Number
|
* Get UDP Port Number
|
||||||
@ -192,7 +192,6 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
int getNumberofUDPInterfaces() const;
|
int getNumberofUDPInterfaces() const;
|
||||||
|
|
||||||
|
|
||||||
//***acquisition parameters***
|
//***acquisition parameters***
|
||||||
/**
|
/**
|
||||||
* Get ROI
|
* Get ROI
|
||||||
@ -224,7 +223,6 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
bool getDataStreamEnable() const;
|
bool getDataStreamEnable() const;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Acquisition Period
|
* Get Acquisition Period
|
||||||
* @return acquisition period
|
* @return acquisition period
|
||||||
@ -251,19 +249,22 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Get Number of Frames expected by receiver from detector
|
* 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
|
* @return number of frames expected
|
||||||
*/
|
*/
|
||||||
uint64_t getNumberOfFrames() const;
|
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
|
* @return number of Analog samples expected
|
||||||
*/
|
*/
|
||||||
uint64_t getNumberofAnalogSamples() const;
|
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
|
* @return number of Digital samples expected
|
||||||
*/
|
*/
|
||||||
uint64_t getNumberofDigitalSamples() const;
|
uint64_t getNumberofDigitalSamples() const;
|
||||||
@ -286,11 +287,11 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
uint32_t getFifoDepth() const;
|
uint32_t getFifoDepth() const;
|
||||||
|
|
||||||
|
|
||||||
//***receiver status***
|
//***receiver status***
|
||||||
/**
|
/**
|
||||||
* Get Listening Status of Receiver
|
* 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;
|
runStatus getStatus() const;
|
||||||
|
|
||||||
@ -304,7 +305,7 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
* Get CTB digital bits enable list
|
* Get CTB digital bits enable list
|
||||||
* @returns digital bits enable list
|
* @returns digital bits enable list
|
||||||
*/
|
*/
|
||||||
std::vector <int> getDbitList() const;
|
std::vector<int> getDbitList() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get CTB digital bits offset
|
* Get CTB digital bits offset
|
||||||
@ -314,16 +315,16 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get activate
|
* Get activate
|
||||||
* If deactivated, receiver will create dummy data if deactivated padding is enabled
|
* If deactivated, receiver will create dummy data if deactivated padding is
|
||||||
* (as it will receive nothing from detector)
|
* enabled (as it will receive nothing from detector)
|
||||||
* @return false for deactivated, true for activated
|
* @return false for deactivated, true for activated
|
||||||
*/
|
*/
|
||||||
bool getActivate() const;
|
bool getActivate() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get deactivated padding enable
|
* Get deactivated padding enable
|
||||||
* If enabled, receiver will create dummy packets (0xFF), else it will create nothing
|
* If enabled, receiver will create dummy packets (0xFF), else it will
|
||||||
* (as it will receive nothing from detector)
|
* create nothing (as it will receive nothing from detector)
|
||||||
* @return 0 for disabled, 1 for enabled
|
* @return 0 for disabled, 1 for enabled
|
||||||
*/
|
*/
|
||||||
bool getDeactivatedPadding() const;
|
bool getDeactivatedPadding() const;
|
||||||
@ -352,7 +353,6 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
int64_t getUDPSocketBufferSize() const;
|
int64_t getUDPSocketBufferSize() const;
|
||||||
|
|
||||||
|
|
||||||
/** (not saved in client shared memory)
|
/** (not saved in client shared memory)
|
||||||
* Get actual UDP Socket Buffer Size
|
* Get actual UDP Socket Buffer Size
|
||||||
* @return actual UDP Socket Buffer Size
|
* @return actual UDP Socket Buffer Size
|
||||||
@ -375,13 +375,13 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
* Set multi detector size
|
* Set multi detector size
|
||||||
* @param pointer to array of multi detector size in every dimension
|
* @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'
|
* Get flipped data across 'axis'
|
||||||
* @return if data is flipped 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)
|
* Set Gap Pixels Enable (eiger specific)
|
||||||
@ -397,7 +397,6 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
int setReadOutFlags(const readOutFlags f);
|
int setReadOutFlags(const readOutFlags f);
|
||||||
|
|
||||||
|
|
||||||
//***file parameters***
|
//***file parameters***
|
||||||
/**
|
/**
|
||||||
* Set File Format
|
* Set File Format
|
||||||
@ -406,8 +405,9 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
void setFileFormat(slsDetectorDefs::fileFormat f);
|
void setFileFormat(slsDetectorDefs::fileFormat f);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set File Name Prefix (without frame index, file index and extension (_d0_f000000000000_8.raw))
|
* Set File Name Prefix (without frame index, file index and extension
|
||||||
* Does not check for file existence since it is created only at startReceiver
|
* (_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)
|
* @param c file name (max of 1000 characters)
|
||||||
*/
|
*/
|
||||||
void setFileName(const char c[]);
|
void setFileName(const char c[]);
|
||||||
@ -479,13 +479,13 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
* Set Ethernet Interface to listen to
|
* Set Ethernet Interface to listen to
|
||||||
* @param c ethernet inerface eg. eth0 (max of 1000 characters)
|
* @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)
|
* Set second Ethernet Interface to listen to (jungfrau specific)
|
||||||
* @param c second ethernet inerface eg. eth0 (max of 1000 characters)
|
* @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)
|
* Set number of UDP Interfaces (jungfrau specific)
|
||||||
@ -501,7 +501,6 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
int setUDPSocketBufferSize(const int64_t s);
|
int setUDPSocketBufferSize(const int64_t s);
|
||||||
|
|
||||||
|
|
||||||
//***acquisition parameters***
|
//***acquisition parameters***
|
||||||
/**
|
/**
|
||||||
* Set ROI
|
* Set ROI
|
||||||
@ -551,7 +550,7 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
/**
|
/**
|
||||||
* Set additional json header
|
* Set additional json header
|
||||||
*/
|
*/
|
||||||
void setAdditionalJsonHeader(const char* c);
|
void setAdditionalJsonHeader(const char *c);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Acquisition Period
|
* Set Acquisition Period
|
||||||
@ -583,7 +582,8 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Number of Frames expected by receiver from detector
|
* 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
|
* @param i number of frames expected
|
||||||
*/
|
*/
|
||||||
void setNumberOfFrames(const uint64_t i);
|
void setNumberOfFrames(const uint64_t i);
|
||||||
@ -623,12 +623,11 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
int setFifoDepth(const uint32_t i);
|
int setFifoDepth(const uint32_t i);
|
||||||
|
|
||||||
|
|
||||||
//***receiver parameters***
|
//***receiver parameters***
|
||||||
/**
|
/**
|
||||||
* Activate / Deactivate Receiver
|
* Activate / Deactivate Receiver
|
||||||
* If deactivated, receiver will create dummy data if deactivated padding is enabled
|
* If deactivated, receiver will create dummy data if deactivated padding is
|
||||||
* (as it will receive nothing from detector)
|
* enabled (as it will receive nothing from detector)
|
||||||
* @param enable enable
|
* @param enable enable
|
||||||
* @return false for disabled, true for enabled
|
* @return false for disabled, true for enabled
|
||||||
*/
|
*/
|
||||||
@ -636,8 +635,8 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set deactivated padding enable
|
* Set deactivated padding enable
|
||||||
* If enabled, receiver will create dummy packets (0xFF), else it will create nothing
|
* If enabled, receiver will create dummy packets (0xFF), else it will
|
||||||
* (as it will receive nothing from detector)
|
* create nothing (as it will receive nothing from detector)
|
||||||
* @param enable enable
|
* @param enable enable
|
||||||
* @return false for disabled, true for enabled
|
* @return false for disabled, true for enabled
|
||||||
*/
|
*/
|
||||||
@ -653,7 +652,7 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
* Set CTB digital bits enable list
|
* Set CTB digital bits enable list
|
||||||
* @param v 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
|
* Set CTB digital bits offset
|
||||||
@ -661,7 +660,6 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
void setDbitOffset(const int s);
|
void setDbitOffset(const int s);
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* Behavioral functions***************************************************
|
* Behavioral functions***************************************************
|
||||||
* They may modify the status of the receiver ****************************
|
* They may modify the status of the receiver ****************************
|
||||||
@ -669,8 +667,9 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
|
|
||||||
//***initial functions***
|
//***initial functions***
|
||||||
/**
|
/**
|
||||||
* Set receiver type (and corresponding detector variables in derived STANDARD class)
|
* Set receiver type (and corresponding detector variables in derived
|
||||||
* It is the first function called by the client when connecting to receiver
|
* STANDARD class) It is the first function called by the client when
|
||||||
|
* connecting to receiver
|
||||||
* @param d detector type
|
* @param d detector type
|
||||||
* @return OK or FAIL
|
* @return OK or FAIL
|
||||||
*/
|
*/
|
||||||
@ -684,34 +683,37 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
|
|
||||||
//***acquisition functions***
|
//***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();
|
void resetAcquisitionCount();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start Listening for Packets by activating all configuration settings to receiver
|
* Start Listening for Packets by activating all configuration settings to
|
||||||
* When this function returns, it has status RUNNING(upon SUCCESS) or IDLE (upon failure)
|
* receiver When this function returns, it has status RUNNING(upon SUCCESS)
|
||||||
|
* or IDLE (upon failure)
|
||||||
* @param c error message if FAIL
|
* @param c error message if FAIL
|
||||||
* @return OK or FAIL
|
* @return OK or FAIL
|
||||||
*/
|
*/
|
||||||
int startReceiver(char *c=NULL);
|
int startReceiver(char *c = NULL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop Listening for Packets
|
* Stop Listening for Packets
|
||||||
* Calls startReadout(), which stops listening and sets status to Transmitting
|
* Calls startReadout(), which stops listening and sets status to
|
||||||
* When it has read every frame in buffer, the status changes to Run_Finished
|
* Transmitting When it has read every frame in buffer, the status changes
|
||||||
* When this function returns, receiver has status IDLE
|
* to Run_Finished When this function returns, receiver has status IDLE Pre:
|
||||||
* Pre: status is running, semaphores have been instantiated,
|
* status is running, semaphores have been instantiated, Post: udp sockets
|
||||||
* Post: udp sockets shut down, status is idle, semaphores destroyed
|
* shut down, status is idle, semaphores destroyed
|
||||||
*/
|
*/
|
||||||
void stopReceiver();
|
void stopReceiver();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop Listening to Packets
|
* Stop Listening to Packets
|
||||||
* and sets status to Transmitting
|
* and sets status to Transmitting
|
||||||
* Next step would be to get all data and stop receiver completely and return with idle state
|
* Next step would be to get all data and stop receiver completely and
|
||||||
* Pre: status is running, udp sockets have been initialized, stop receiver initiated
|
* return with idle state Pre: status is running, udp sockets have been
|
||||||
* Post:udp sockets closed, status is transmitting
|
* initialized, stop receiver initiated Post:udp sockets closed, status is
|
||||||
|
* transmitting
|
||||||
*/
|
*/
|
||||||
void startReadout();
|
void startReadout();
|
||||||
|
|
||||||
@ -745,14 +747,17 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
* we write depending on file write enable
|
* we write depending on file write enable
|
||||||
* users get data to write depending on call backs registered
|
* 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
|
* Call back for acquisition finished
|
||||||
* callback argument is
|
* callback argument is
|
||||||
* total frames caught
|
* 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
|
* Call back for raw data
|
||||||
@ -761,8 +766,9 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
* dataPointer is the pointer to the data
|
* dataPointer is the pointer to the data
|
||||||
* dataSize in bytes is the size of the data in bytes.
|
* dataSize in bytes is the size of the data in bytes.
|
||||||
*/
|
*/
|
||||||
void registerCallBackRawDataReady(void (*func)(char* ,
|
void registerCallBackRawDataReady(void (*func)(char *, char *, uint32_t,
|
||||||
char*, uint32_t, void*),void *arg);
|
void *),
|
||||||
|
void *arg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call back for raw data (modified)
|
* Call back for raw data (modified)
|
||||||
@ -770,13 +776,14 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
|||||||
* sls_receiver_header frame metadata
|
* sls_receiver_header frame metadata
|
||||||
* dataPointer is the pointer to the data
|
* dataPointer is the pointer to the data
|
||||||
* revDatasize is the reference of data size in bytes.
|
* 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* ,
|
void registerCallBackRawDataModifyReady(void (*func)(char *, char *,
|
||||||
char*, uint32_t &,void*),void *arg);
|
uint32_t &, void *),
|
||||||
|
void *arg);
|
||||||
private:
|
|
||||||
|
|
||||||
|
private:
|
||||||
/**
|
/**
|
||||||
* Delete and free member parameters
|
* Delete and free member parameters
|
||||||
*/
|
*/
|
||||||
@ -829,8 +836,6 @@ private:
|
|||||||
*/
|
*/
|
||||||
void StartRunning();
|
void StartRunning();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* Class Members *********************************************************
|
* Class Members *********************************************************
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
@ -888,7 +893,7 @@ private:
|
|||||||
/** silent mode */
|
/** silent mode */
|
||||||
bool silentMode;
|
bool silentMode;
|
||||||
/** ctb digital bits enabled list (empty: all enabled) */
|
/** ctb digital bits enabled list (empty: all enabled) */
|
||||||
std::vector <int> ctbDbitList;
|
std::vector<int> ctbDbitList;
|
||||||
/** ctb digital bit offset in bytes */
|
/** ctb digital bit offset in bytes */
|
||||||
int ctbDbitOffset;
|
int ctbDbitOffset;
|
||||||
/* analog data bytes */
|
/* analog data bytes */
|
||||||
@ -909,7 +914,8 @@ private:
|
|||||||
//***file parameters***
|
//***file parameters***
|
||||||
/** File format */
|
/** File format */
|
||||||
fileFormat fileFormatType;
|
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];
|
char fileName[MAX_STR_LENGTH];
|
||||||
/** File Path */
|
/** File Path */
|
||||||
char filePath[MAX_STR_LENGTH];
|
char filePath[MAX_STR_LENGTH];
|
||||||
@ -944,7 +950,7 @@ private:
|
|||||||
|
|
||||||
//** class objects ***
|
//** class objects ***
|
||||||
/** General Data Properties */
|
/** General Data Properties */
|
||||||
GeneralData* generalData;
|
GeneralData *generalData;
|
||||||
/** Listener Objects that listen to UDP and push into fifo */
|
/** Listener Objects that listen to UDP and push into fifo */
|
||||||
std::vector<std::unique_ptr<Listener>> listener;
|
std::vector<std::unique_ptr<Listener>> listener;
|
||||||
/** DataProcessor Objects that pull from fifo and process data */
|
/** DataProcessor Objects that pull from fifo and process data */
|
||||||
@ -967,14 +973,14 @@ private:
|
|||||||
* we write depending on file write enable
|
* we write depending on file write enable
|
||||||
* users get data to write depending on call backs registered
|
* 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;
|
void *pStartAcquisition;
|
||||||
/**
|
/**
|
||||||
* Call back for acquisition finished
|
* Call back for acquisition finished
|
||||||
* callback argument is
|
* callback argument is
|
||||||
* total frames caught
|
* total frames caught
|
||||||
*/
|
*/
|
||||||
void (*acquisitionFinishedCallBack)(uint64_t, void*);
|
void (*acquisitionFinishedCallBack)(uint64_t, void *);
|
||||||
void *pAcquisitionFinished;
|
void *pAcquisitionFinished;
|
||||||
/**
|
/**
|
||||||
* Call back for raw data
|
* Call back for raw data
|
||||||
@ -983,20 +989,16 @@ private:
|
|||||||
* dataPointer is the pointer to the data
|
* dataPointer is the pointer to the data
|
||||||
* dataSize in bytes is the size of the data in bytes.
|
* dataSize in bytes is the size of the data in bytes.
|
||||||
*/
|
*/
|
||||||
void (*rawDataReadyCallBack)(char* ,
|
void (*rawDataReadyCallBack)(char *, char *, uint32_t, void *);
|
||||||
char*, uint32_t, void*);
|
|
||||||
/**
|
/**
|
||||||
* Call back for raw data (modified)
|
* Call back for raw data (modified)
|
||||||
* args to raw data ready callback are
|
* args to raw data ready callback are
|
||||||
* sls_receiver_header frame metadata
|
* sls_receiver_header frame metadata
|
||||||
* dataPointer is the pointer to the data
|
* 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* ,
|
void (*rawDataModifyReadyCallBack)(char *, char *, uint32_t &, void *);
|
||||||
char*, uint32_t &, void*);
|
|
||||||
|
|
||||||
void *pRawDataReady;
|
void *pRawDataReady;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
/********************************************//**
|
/********************************************/ /**
|
||||||
* @file slsReceiverTCPIPInterface.h
|
* @file
|
||||||
* @short interface between receiver and client
|
*slsReceiverTCPIPInterface.h
|
||||||
|
* @short interface between
|
||||||
|
*receiver and client
|
||||||
***********************************************/
|
***********************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "sls_detector_defs.h"
|
|
||||||
#include "receiver_defs.h"
|
#include "receiver_defs.h"
|
||||||
|
#include "sls_detector_defs.h"
|
||||||
|
|
||||||
class MySocketTCP;
|
class MySocketTCP;
|
||||||
class ServerInterface;
|
class ServerInterface;
|
||||||
#include "slsReceiverImplementation.h"
|
|
||||||
#include "ServerSocket.h"
|
#include "ServerSocket.h"
|
||||||
|
#include "slsReceiverImplementation.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@short interface between receiver and client
|
*@short interface between receiver and client
|
||||||
@ -20,10 +20,9 @@ class ServerInterface;
|
|||||||
|
|
||||||
class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
||||||
private:
|
private:
|
||||||
enum numberMode {DEC, HEX};
|
enum numberMode { DEC, HEX };
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** Destructor */
|
/** Destructor */
|
||||||
virtual ~slsReceiverTCPIPInterface();
|
virtual ~slsReceiverTCPIPInterface();
|
||||||
|
|
||||||
@ -34,7 +33,7 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
|||||||
* @param pn port number (defaults to default port number)
|
* @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
|
* 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 */
|
/** stop listening on the TCP & UDP port for client comminication */
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
|
|
||||||
/** gets version */
|
/** gets version */
|
||||||
int64_t getReceiverVersion();
|
int64_t getReceiverVersion();
|
||||||
|
|
||||||
@ -62,14 +60,17 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
|||||||
* we write depending on file write enable
|
* we write depending on file write enable
|
||||||
* users get data to write depending on call backs registered
|
* 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
|
* Call back for acquisition finished
|
||||||
* callback argument is
|
* callback argument is
|
||||||
* total frames caught
|
* 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
|
* Call back for raw data
|
||||||
@ -78,8 +79,9 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
|||||||
* dataPointer is the pointer to the data
|
* dataPointer is the pointer to the data
|
||||||
* dataSize in bytes is the size of the data in bytes.
|
* dataSize in bytes is the size of the data in bytes.
|
||||||
*/
|
*/
|
||||||
void registerCallBackRawDataReady(void (*func)(char* ,
|
void registerCallBackRawDataReady(void (*func)(char *, char *, uint32_t,
|
||||||
char*, uint32_t, void*),void *arg);
|
void *),
|
||||||
|
void *arg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call back for raw data (modified)
|
* Call back for raw data (modified)
|
||||||
@ -87,21 +89,20 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
|||||||
* sls_receiver_header frame metadata
|
* sls_receiver_header frame metadata
|
||||||
* dataPointer is the pointer to the data
|
* dataPointer is the pointer to the data
|
||||||
* revDatasize is the reference of data size in bytes.
|
* 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* ,
|
void registerCallBackRawDataModifyReady(void (*func)(char *, char *,
|
||||||
char*, uint32_t &,void*),void *arg);
|
uint32_t &, void *),
|
||||||
|
void *arg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Static function - Thread started which is a TCP server
|
* Static function - Thread started which is a TCP server
|
||||||
* Called by start()
|
* Called by start()
|
||||||
* @param this_pointer pointer to this object
|
* @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
|
* Thread started which is a TCP server
|
||||||
@ -300,7 +301,8 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
|||||||
std::unique_ptr<slsReceiverImplementation> receiver{nullptr};
|
std::unique_ptr<slsReceiverImplementation> receiver{nullptr};
|
||||||
|
|
||||||
/** Function List */
|
/** Function List */
|
||||||
int (slsReceiverTCPIPInterface::*flist[NUM_REC_FUNCTIONS])(sls::ServerInterface2& socket);
|
int (slsReceiverTCPIPInterface::*flist[NUM_REC_FUNCTIONS])(
|
||||||
|
sls::ServerInterface2 &socket);
|
||||||
|
|
||||||
/** Message */
|
/** Message */
|
||||||
char mess[MAX_STR_LENGTH]{};
|
char mess[MAX_STR_LENGTH]{};
|
||||||
@ -339,7 +341,8 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
|||||||
* we write depending on file write enable
|
* we write depending on file write enable
|
||||||
* users get data to write depending on call backs registered
|
* 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};
|
void *pStartAcquisition{nullptr};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -347,10 +350,9 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
|||||||
* callback argument is
|
* callback argument is
|
||||||
* total frames caught
|
* total frames caught
|
||||||
*/
|
*/
|
||||||
void (*acquisitionFinishedCallBack)(uint64_t, void*) = nullptr;
|
void (*acquisitionFinishedCallBack)(uint64_t, void *) = nullptr;
|
||||||
void *pAcquisitionFinished{nullptr};
|
void *pAcquisitionFinished{nullptr};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call back for raw data
|
* Call back for raw data
|
||||||
* args to raw data ready callback are
|
* args to raw data ready callback are
|
||||||
@ -358,37 +360,34 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
|||||||
* dataPointer is the pointer to the data
|
* dataPointer is the pointer to the data
|
||||||
* dataSize in bytes is the size of the data in bytes.
|
* dataSize in bytes is the size of the data in bytes.
|
||||||
*/
|
*/
|
||||||
void (*rawDataReadyCallBack)(char* ,
|
void (*rawDataReadyCallBack)(char *, char *, uint32_t, void *) = nullptr;
|
||||||
char*, uint32_t, void*) = nullptr;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call back for raw data (modified)
|
* Call back for raw data (modified)
|
||||||
* args to raw data ready callback are
|
* args to raw data ready callback are
|
||||||
* sls_receiver_header frame metadata
|
* sls_receiver_header frame metadata
|
||||||
* dataPointer is the pointer to the data
|
* 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* ,
|
void (*rawDataModifyReadyCallBack)(char *, char *, uint32_t &,
|
||||||
char*, uint32_t &, void*) = nullptr;
|
void *) = nullptr;
|
||||||
|
|
||||||
void *pRawDataReady{nullptr};
|
void *pRawDataReady{nullptr};
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
|
|
||||||
std::unique_ptr<sls::ServerSocket> server{nullptr};
|
std::unique_ptr<sls::ServerSocket> server{nullptr};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void VerifyLock();
|
void VerifyLock();
|
||||||
void VerifyIdle(sls::ServerInterface2& socket);
|
void VerifyIdle(sls::ServerInterface2 &socket);
|
||||||
|
|
||||||
slsReceiverImplementation* impl(){
|
slsReceiverImplementation *impl() {
|
||||||
if (receiver!=nullptr){
|
if (receiver != nullptr) {
|
||||||
return receiver.get();
|
return receiver.get();
|
||||||
}else{
|
} 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
|
* @file
|
||||||
* @short interface between receiver and client
|
*slsReceiverTCPIPInterface.cpp
|
||||||
|
* @short interface between
|
||||||
|
*receiver and client
|
||||||
***********************************************/
|
***********************************************/
|
||||||
|
|
||||||
|
#include "slsReceiverTCPIPInterface.h"
|
||||||
#include "FixedCapacityContainer.h"
|
#include "FixedCapacityContainer.h"
|
||||||
#include "ServerSocket.h"
|
#include "ServerSocket.h"
|
||||||
#include "slsReceiver.h"
|
#include "slsReceiver.h"
|
||||||
#include "slsReceiverImplementation.h"
|
#include "slsReceiverImplementation.h"
|
||||||
#include "slsReceiverTCPIPInterface.h"
|
|
||||||
#include "slsReceiverUsers.h"
|
#include "slsReceiverUsers.h"
|
||||||
#include "versionAPI.h"
|
|
||||||
#include "string_utils.h"
|
|
||||||
#include "sls_detector_exceptions.h"
|
#include "sls_detector_exceptions.h"
|
||||||
|
#include "string_utils.h"
|
||||||
|
#include "versionAPI.h"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@ -24,26 +25,22 @@
|
|||||||
#include <syscall.h>
|
#include <syscall.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
using sls::SocketError;
|
|
||||||
using sls::RuntimeError;
|
using sls::RuntimeError;
|
||||||
|
using sls::SocketError;
|
||||||
using Interface = sls::ServerInterface2;
|
using Interface = sls::ServerInterface2;
|
||||||
|
|
||||||
slsReceiverTCPIPInterface::~slsReceiverTCPIPInterface() {
|
slsReceiverTCPIPInterface::~slsReceiverTCPIPInterface() { stop(); }
|
||||||
stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int pn):
|
slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int pn)
|
||||||
myDetectorType(GOTTHARD),
|
: myDetectorType(GOTTHARD), portNumber(pn > 0 ? pn : DEFAULT_PORTNO + 2) {
|
||||||
portNumber(pn > 0 ? pn : DEFAULT_PORTNO + 2)
|
|
||||||
{
|
|
||||||
function_table();
|
function_table();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int slsReceiverTCPIPInterface::start() {
|
||||||
int slsReceiverTCPIPInterface::start(){
|
|
||||||
FILE_LOG(logDEBUG) << "Creating TCP Server Thread";
|
FILE_LOG(logDEBUG) << "Creating TCP Server Thread";
|
||||||
killTCPServerThread = 0;
|
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";
|
FILE_LOG(logERROR) << "Could not create TCP Server thread";
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -52,58 +49,56 @@ int slsReceiverTCPIPInterface::start(){
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void slsReceiverTCPIPInterface::stop() {
|
||||||
void slsReceiverTCPIPInterface::stop(){
|
|
||||||
if (tcpThreadCreated) {
|
if (tcpThreadCreated) {
|
||||||
FILE_LOG(logINFO) << "Shutting down TCP Socket on port " << portNumber;
|
FILE_LOG(logINFO) << "Shutting down TCP Socket on port " << portNumber;
|
||||||
killTCPServerThread = 1;
|
killTCPServerThread = 1;
|
||||||
if(server)
|
if (server)
|
||||||
server->shutDownSocket();
|
server->shutDownSocket();
|
||||||
FILE_LOG(logDEBUG) << "TCP Socket closed on port " << portNumber;
|
FILE_LOG(logDEBUG) << "TCP Socket closed on port " << portNumber;
|
||||||
pthread_join(TCPServer_thread, nullptr);
|
pthread_join(TCPServer_thread, nullptr);
|
||||||
tcpThreadCreated = false;
|
tcpThreadCreated = false;
|
||||||
killTCPServerThread = 0;
|
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***/
|
/***callback functions***/
|
||||||
void slsReceiverTCPIPInterface::registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg){
|
void slsReceiverTCPIPInterface::registerCallBackStartAcquisition(
|
||||||
startAcquisitionCallBack=func;
|
int (*func)(char *, char *, uint64_t, uint32_t, void *), void *arg) {
|
||||||
pStartAcquisition=arg;
|
startAcquisitionCallBack = func;
|
||||||
|
pStartAcquisition = arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void slsReceiverTCPIPInterface::registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg){
|
void slsReceiverTCPIPInterface::registerCallBackAcquisitionFinished(
|
||||||
acquisitionFinishedCallBack=func;
|
void (*func)(uint64_t, void *), void *arg) {
|
||||||
pAcquisitionFinished=arg;
|
acquisitionFinishedCallBack = func;
|
||||||
|
pAcquisitionFinished = arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void slsReceiverTCPIPInterface::registerCallBackRawDataReady(void (*func)(char* ,
|
void slsReceiverTCPIPInterface::registerCallBackRawDataReady(
|
||||||
char*, uint32_t, void*),void *arg){
|
void (*func)(char *, char *, uint32_t, void *), void *arg) {
|
||||||
rawDataReadyCallBack=func;
|
rawDataReadyCallBack = func;
|
||||||
pRawDataReady=arg;
|
pRawDataReady = arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void slsReceiverTCPIPInterface::registerCallBackRawDataModifyReady(void (*func)(char* ,
|
void slsReceiverTCPIPInterface::registerCallBackRawDataModifyReady(
|
||||||
char*, uint32_t &,void*),void *arg){
|
void (*func)(char *, char *, uint32_t &, void *), void *arg) {
|
||||||
rawDataModifyReadyCallBack=func;
|
rawDataModifyReadyCallBack = func;
|
||||||
pRawDataReady=arg;
|
pRawDataReady = arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* slsReceiverTCPIPInterface::startTCPServerThread(void *this_pointer){
|
void *slsReceiverTCPIPInterface::startTCPServerThread(void *this_pointer) {
|
||||||
((slsReceiverTCPIPInterface*)this_pointer)->startTCPServer();
|
((slsReceiverTCPIPInterface *)this_pointer)->startTCPServer();
|
||||||
return this_pointer;
|
return this_pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void slsReceiverTCPIPInterface::startTCPServer() {
|
void slsReceiverTCPIPInterface::startTCPServer() {
|
||||||
FILE_LOG(logINFOBLUE) << "Created [ TCP server Tid: "
|
FILE_LOG(logINFOBLUE) << "Created [ TCP server Tid: " << syscall(SYS_gettid)
|
||||||
<< syscall(SYS_gettid) << "]";
|
<< "]";
|
||||||
FILE_LOG(logINFO) << "SLS Receiver starting TCP Server on port "
|
FILE_LOG(logINFO) << "SLS Receiver starting TCP Server on port "
|
||||||
<< portNumber << '\n';
|
<< portNumber << '\n';
|
||||||
server = sls::make_unique<sls::ServerSocket>(portNumber);
|
server = sls::make_unique<sls::ServerSocket>(portNumber);
|
||||||
@ -111,18 +106,17 @@ void slsReceiverTCPIPInterface::startTCPServer() {
|
|||||||
FILE_LOG(logDEBUG1) << "Start accept loop";
|
FILE_LOG(logDEBUG1) << "Start accept loop";
|
||||||
try {
|
try {
|
||||||
auto socket = server->accept();
|
auto socket = server->accept();
|
||||||
try{
|
try {
|
||||||
VerifyLock();
|
VerifyLock();
|
||||||
ret = decode_function(socket);
|
ret = decode_function(socket);
|
||||||
}catch(const RuntimeError& e){
|
} catch (const RuntimeError &e) {
|
||||||
//We had an error needs to be sent to client
|
// We had an error needs to be sent to client
|
||||||
int r = FAIL;
|
int r = FAIL;
|
||||||
strcpy(mess, e.what());
|
strcpy(mess, e.what());
|
||||||
socket.write(&r, sizeof(r));
|
socket.write(&r, sizeof(r));
|
||||||
socket.write(mess, sizeof(mess));
|
socket.write(mess, sizeof(mess));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// if tcp command was to exit server
|
// if tcp command was to exit server
|
||||||
if (ret == GOODBYE) {
|
if (ret == GOODBYE) {
|
||||||
FILE_LOG(logINFO) << "Shutting down UDP Socket";
|
FILE_LOG(logINFO) << "Shutting down UDP Socket";
|
||||||
@ -134,7 +128,7 @@ void slsReceiverTCPIPInterface::startTCPServer() {
|
|||||||
<< "]";
|
<< "]";
|
||||||
pthread_exit(nullptr);
|
pthread_exit(nullptr);
|
||||||
}
|
}
|
||||||
}catch(const RuntimeError& e){
|
} catch (const RuntimeError &e) {
|
||||||
std::cout << "Accept failed\n";
|
std::cout << "Accept failed\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +145,7 @@ void slsReceiverTCPIPInterface::startTCPServer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// clang-format off
|
||||||
int slsReceiverTCPIPInterface::function_table(){
|
int slsReceiverTCPIPInterface::function_table(){
|
||||||
flist[F_EXEC_RECEIVER_COMMAND] = &slsReceiverTCPIPInterface::exec_command;
|
flist[F_EXEC_RECEIVER_COMMAND] = &slsReceiverTCPIPInterface::exec_command;
|
||||||
flist[F_EXIT_RECEIVER] = &slsReceiverTCPIPInterface::exit_server;
|
flist[F_EXIT_RECEIVER] = &slsReceiverTCPIPInterface::exit_server;
|
||||||
@ -215,7 +209,7 @@ int slsReceiverTCPIPInterface::function_table(){
|
|||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
// clang-format on
|
||||||
int slsReceiverTCPIPInterface::decode_function(Interface &socket) {
|
int slsReceiverTCPIPInterface::decode_function(Interface &socket) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
socket.receiveArg(fnum);
|
socket.receiveArg(fnum);
|
||||||
@ -241,21 +235,24 @@ void slsReceiverTCPIPInterface::functionNotImplemented() {
|
|||||||
throw RuntimeError(mess);
|
throw RuntimeError(mess);
|
||||||
}
|
}
|
||||||
|
|
||||||
void slsReceiverTCPIPInterface::modeNotImplemented(std::string modename, int mode) {
|
void slsReceiverTCPIPInterface::modeNotImplemented(std::string modename,
|
||||||
|
int mode) {
|
||||||
char message[MAX_STR_LENGTH];
|
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);
|
throw RuntimeError(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
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 (ret == OK && arg != -1 && retval != arg) {
|
||||||
if (hex)
|
if (hex)
|
||||||
sprintf(mess, "Could not %s. Set 0x%x, but read 0x%x\n",
|
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
|
else
|
||||||
sprintf(mess, "Could not %s. Set %d, but read %d\n",
|
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);
|
throw RuntimeError(mess);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -310,7 +307,7 @@ int slsReceiverTCPIPInterface::lock_receiver(Interface &socket) {
|
|||||||
lockStatus = lock;
|
lockStatus = lock;
|
||||||
lock ? server->setLockedBy(server->getThisClient())
|
lock ? server->setLockedBy(server->getThisClient())
|
||||||
: server->setLockedBy(sls::IpAddr{});
|
: server->setLockedBy(sls::IpAddr{});
|
||||||
} else{
|
} else {
|
||||||
throw RuntimeError("Receiver locked\n");
|
throw RuntimeError("Receiver locked\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -325,13 +322,13 @@ int slsReceiverTCPIPInterface::get_last_client_ip(Interface &socket) {
|
|||||||
return socket.sendResult(ret, &ip, sizeof(ip));
|
return socket.sendResult(ret, &ip, sizeof(ip));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_port(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_port(Interface &socket) {
|
||||||
auto p_number = socket.receive<int>();
|
auto p_number = socket.receive<int>();
|
||||||
if (p_number < 1024)
|
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);
|
auto new_server = sls::make_unique<sls::ServerSocket>(p_number);
|
||||||
new_server->setLockedBy(server->getLockedBy());
|
new_server->setLockedBy(server->getLockedBy());
|
||||||
new_server->setLastClient(server->getThisClient());
|
new_server->setLastClient(server->getThisClient());
|
||||||
@ -341,14 +338,13 @@ int slsReceiverTCPIPInterface::set_port(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::update_client(Interface &socket) {
|
int slsReceiverTCPIPInterface::update_client(Interface &socket) {
|
||||||
if(receiver == nullptr)
|
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);
|
socket.sendData(OK);
|
||||||
return send_update(socket);
|
return send_update(socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::send_update(Interface &socket) {
|
int slsReceiverTCPIPInterface::send_update(Interface &socket) {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
int i32 = -1;
|
int i32 = -1;
|
||||||
@ -356,7 +352,7 @@ int slsReceiverTCPIPInterface::send_update(Interface &socket) {
|
|||||||
|
|
||||||
char ip[INET_ADDRSTRLEN]{};
|
char ip[INET_ADDRSTRLEN]{};
|
||||||
sls::strcpy_safe(ip, server->getLastClient().str().c_str());
|
sls::strcpy_safe(ip, server->getLastClient().str().c_str());
|
||||||
n += socket.sendData(ip,sizeof(ip));
|
n += socket.sendData(ip, sizeof(ip));
|
||||||
|
|
||||||
// filepath
|
// filepath
|
||||||
strcpy(cstring, receiver->getFilePath().c_str());
|
strcpy(cstring, receiver->getFilePath().c_str());
|
||||||
@ -367,47 +363,47 @@ int slsReceiverTCPIPInterface::send_update(Interface &socket) {
|
|||||||
n += socket.sendData(cstring, sizeof(cstring));
|
n += socket.sendData(cstring, sizeof(cstring));
|
||||||
|
|
||||||
// index
|
// index
|
||||||
i32=receiver->getFileIndex();
|
i32 = receiver->getFileIndex();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.sendData(&i32, sizeof(i32));
|
||||||
|
|
||||||
//file format
|
// file format
|
||||||
i32=(int)receiver->getFileFormat();
|
i32 = (int)receiver->getFileFormat();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.sendData(&i32, sizeof(i32));
|
||||||
|
|
||||||
//frames per file
|
// frames per file
|
||||||
i32=(int)receiver->getFramesPerFile();
|
i32 = (int)receiver->getFramesPerFile();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.sendData(&i32, sizeof(i32));
|
||||||
|
|
||||||
//frame discard policy
|
// frame discard policy
|
||||||
i32=(int)receiver->getFrameDiscardPolicy();
|
i32 = (int)receiver->getFrameDiscardPolicy();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.sendData(&i32, sizeof(i32));
|
||||||
|
|
||||||
//frame padding
|
// frame padding
|
||||||
i32=(int)receiver->getFramePaddingEnable();
|
i32 = (int)receiver->getFramePaddingEnable();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.sendData(&i32, sizeof(i32));
|
||||||
|
|
||||||
// file write enable
|
// file write enable
|
||||||
i32=(int)receiver->getFileWriteEnable();
|
i32 = (int)receiver->getFileWriteEnable();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.sendData(&i32, sizeof(i32));
|
||||||
|
|
||||||
// master file write enable
|
// master file write enable
|
||||||
i32=(int)receiver->getMasterFileWriteEnable();
|
i32 = (int)receiver->getMasterFileWriteEnable();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.sendData(&i32, sizeof(i32));
|
||||||
|
|
||||||
// file overwrite enable
|
// file overwrite enable
|
||||||
i32=(int)receiver->getOverwriteEnable();
|
i32 = (int)receiver->getOverwriteEnable();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.sendData(&i32, sizeof(i32));
|
||||||
|
|
||||||
// gap pixels
|
// gap pixels
|
||||||
i32=(int)receiver->getGapPixelsEnable();
|
i32 = (int)receiver->getGapPixelsEnable();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.sendData(&i32, sizeof(i32));
|
||||||
|
|
||||||
// streaming frequency
|
// streaming frequency
|
||||||
i32=(int)receiver->getStreamingFrequency();
|
i32 = (int)receiver->getStreamingFrequency();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.sendData(&i32, sizeof(i32));
|
||||||
|
|
||||||
// streaming port
|
// streaming port
|
||||||
i32=(int)receiver->getStreamingPort();
|
i32 = (int)receiver->getStreamingPort();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.sendData(&i32, sizeof(i32));
|
||||||
|
|
||||||
// streaming source ip
|
// streaming source ip
|
||||||
@ -419,24 +415,24 @@ int slsReceiverTCPIPInterface::send_update(Interface &socket) {
|
|||||||
n += socket.sendData(cstring, sizeof(cstring));
|
n += socket.sendData(cstring, sizeof(cstring));
|
||||||
|
|
||||||
// data streaming enable
|
// data streaming enable
|
||||||
i32=(int)receiver->getDataStreamEnable();
|
i32 = (int)receiver->getDataStreamEnable();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.sendData(&i32, sizeof(i32));
|
||||||
|
|
||||||
// activate
|
// activate
|
||||||
i32=(int)receiver->getActivate();
|
i32 = (int)receiver->getActivate();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.sendData(&i32, sizeof(i32));
|
||||||
|
|
||||||
// deactivated padding enable
|
// deactivated padding enable
|
||||||
i32=(int)receiver->getDeactivatedPadding();
|
i32 = (int)receiver->getDeactivatedPadding();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.sendData(&i32, sizeof(i32));
|
||||||
|
|
||||||
// silent mode
|
// silent mode
|
||||||
i32=(int)receiver->getSilentMode();
|
i32 = (int)receiver->getSilentMode();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.sendData(&i32, sizeof(i32));
|
||||||
|
|
||||||
// dbit list
|
// dbit list
|
||||||
{
|
{
|
||||||
std::vector <int> list = receiver->getDbitList();
|
std::vector<int> list = receiver->getDbitList();
|
||||||
int retvalsize = list.size();
|
int retvalsize = list.size();
|
||||||
int retval[retvalsize];
|
int retval[retvalsize];
|
||||||
std::copy(std::begin(list), std::end(list), retval);
|
std::copy(std::begin(list), std::end(list), retval);
|
||||||
@ -445,25 +441,26 @@ int slsReceiverTCPIPInterface::send_update(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// dbit offset
|
// dbit offset
|
||||||
i32=receiver->getDbitOffset();
|
i32 = receiver->getDbitOffset();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.sendData(&i32, sizeof(i32));
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::get_id(Interface &socket){
|
int slsReceiverTCPIPInterface::get_id(Interface &socket) {
|
||||||
return socket.sendResult(getReceiverVersion());
|
return socket.sendResult(getReceiverVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_detector_type(Interface &socket){
|
int slsReceiverTCPIPInterface::set_detector_type(Interface &socket) {
|
||||||
auto arg = socket.receive<detectorType>();
|
auto arg = socket.receive<detectorType>();
|
||||||
// set
|
// set
|
||||||
if (arg >= 0) {
|
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
|
||||||
if (receiver != nullptr){
|
// (connecting first time)
|
||||||
|
if (receiver != nullptr) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
}
|
}
|
||||||
switch(arg) {
|
switch (arg) {
|
||||||
case GOTTHARD:
|
case GOTTHARD:
|
||||||
case EIGER:
|
case EIGER:
|
||||||
case CHIPTESTBOARD:
|
case CHIPTESTBOARD:
|
||||||
@ -475,24 +472,27 @@ int slsReceiverTCPIPInterface::set_detector_type(Interface &socket){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(receiver == nullptr){
|
if (receiver == nullptr) {
|
||||||
receiver = sls::make_unique<slsReceiverImplementation>();
|
receiver = sls::make_unique<slsReceiverImplementation>();
|
||||||
}
|
}
|
||||||
myDetectorType = arg;
|
myDetectorType = arg;
|
||||||
if (impl()->setDetectorType(myDetectorType) == FAIL){
|
if (impl()->setDetectorType(myDetectorType) == FAIL) {
|
||||||
throw RuntimeError("Could not set detector type");
|
throw RuntimeError("Could not set detector type");
|
||||||
}
|
}
|
||||||
|
|
||||||
// callbacks after (in setdetectortype, the object is reinitialized)
|
// callbacks after (in setdetectortype, the object is reinitialized)
|
||||||
if(startAcquisitionCallBack)
|
if (startAcquisitionCallBack)
|
||||||
impl()->registerCallBackStartAcquisition(startAcquisitionCallBack,pStartAcquisition);
|
impl()->registerCallBackStartAcquisition(startAcquisitionCallBack,
|
||||||
if(acquisitionFinishedCallBack)
|
pStartAcquisition);
|
||||||
impl()->registerCallBackAcquisitionFinished(acquisitionFinishedCallBack,pAcquisitionFinished);
|
if (acquisitionFinishedCallBack)
|
||||||
if(rawDataReadyCallBack)
|
impl()->registerCallBackAcquisitionFinished(
|
||||||
impl()->registerCallBackRawDataReady(rawDataReadyCallBack,pRawDataReady);
|
acquisitionFinishedCallBack, pAcquisitionFinished);
|
||||||
if(rawDataModifyReadyCallBack)
|
if (rawDataReadyCallBack)
|
||||||
impl()->registerCallBackRawDataModifyReady(rawDataModifyReadyCallBack,pRawDataReady);
|
impl()->registerCallBackRawDataReady(rawDataReadyCallBack,
|
||||||
|
pRawDataReady);
|
||||||
|
if (rawDataModifyReadyCallBack)
|
||||||
|
impl()->registerCallBackRawDataModifyReady(
|
||||||
|
rawDataModifyReadyCallBack, pRawDataReady);
|
||||||
}
|
}
|
||||||
return socket.sendResult(myDetectorType);
|
return socket.sendResult(myDetectorType);
|
||||||
}
|
}
|
||||||
@ -514,11 +514,10 @@ int slsReceiverTCPIPInterface::set_detector_hostname(Interface &socket) {
|
|||||||
return socket.sendResult(retval);
|
return socket.sendResult(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_roi(Interface &socket) {
|
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>();
|
auto narg = socket.receive<int>();
|
||||||
std::vector <ROI> arg;
|
std::vector<ROI> arg;
|
||||||
for (int iloop = 0; iloop < narg; ++iloop) {
|
for (int iloop = 0; iloop < narg; ++iloop) {
|
||||||
ROI temp{};
|
ROI temp{};
|
||||||
socket.receiveArg(temp);
|
socket.receiveArg(temp);
|
||||||
@ -526,9 +525,9 @@ int slsReceiverTCPIPInterface::set_roi(Interface &socket) {
|
|||||||
}
|
}
|
||||||
FILE_LOG(logDEBUG1) << "Set ROI narg: " << narg;
|
FILE_LOG(logDEBUG1) << "Set ROI narg: " << narg;
|
||||||
for (int iloop = 0; iloop < narg; ++iloop) {
|
for (int iloop = 0; iloop < narg; ++iloop) {
|
||||||
FILE_LOG(logDEBUG1) << "(" << arg[iloop].xmin << ", " <<
|
FILE_LOG(logDEBUG1)
|
||||||
arg[iloop].xmax << ", " << arg[iloop].ymin << ", " <<
|
<< "(" << arg[iloop].xmin << ", " << arg[iloop].xmax << ", "
|
||||||
arg[iloop].ymax << ")";
|
<< arg[iloop].ymin << ", " << arg[iloop].ymax << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myDetectorType == EIGER || myDetectorType == JUNGFRAU)
|
if (myDetectorType == EIGER || myDetectorType == JUNGFRAU)
|
||||||
@ -540,17 +539,17 @@ int slsReceiverTCPIPInterface::set_roi(Interface &socket) {
|
|||||||
return socket.sendData(OK);
|
return socket.sendData(OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::setup_udp(Interface &socket){
|
int slsReceiverTCPIPInterface::setup_udp(Interface &socket) {
|
||||||
ret = OK;
|
ret = OK;
|
||||||
char args[5][MAX_STR_LENGTH]{};
|
char args[5][MAX_STR_LENGTH]{};
|
||||||
char retvals[2][MAX_STR_LENGTH]{};
|
char retvals[2][MAX_STR_LENGTH]{};
|
||||||
socket.receiveArg(args);
|
socket.receiveArg(args);
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
|
|
||||||
//setup interfaces count
|
// setup interfaces count
|
||||||
int numInterfaces = atoi(args[0]) > 1 ? 2 : 1;
|
int numInterfaces = atoi(args[0]) > 1 ? 2 : 1;
|
||||||
char* ip1 = args[1];
|
char *ip1 = args[1];
|
||||||
char* ip2 = args[2];
|
char *ip2 = args[2];
|
||||||
uint32_t port1 = atoi(args[3]);
|
uint32_t port1 = atoi(args[3]);
|
||||||
uint32_t port2 = atoi(args[4]);
|
uint32_t port2 = atoi(args[4]);
|
||||||
|
|
||||||
@ -562,7 +561,7 @@ int slsReceiverTCPIPInterface::setup_udp(Interface &socket){
|
|||||||
FILE_LOG(logINFO) << "Receiver UDP IP: " << ip1;
|
FILE_LOG(logINFO) << "Receiver UDP IP: " << ip1;
|
||||||
// get eth
|
// get eth
|
||||||
std::string temp = sls::IpToInterfaceName(ip1);
|
std::string temp = sls::IpToInterfaceName(ip1);
|
||||||
if (temp == "none"){
|
if (temp == "none") {
|
||||||
throw RuntimeError("Failed to get ethernet interface or IP");
|
throw RuntimeError("Failed to get ethernet interface or IP");
|
||||||
} else {
|
} else {
|
||||||
char eth[MAX_STR_LENGTH]{};
|
char eth[MAX_STR_LENGTH]{};
|
||||||
@ -570,20 +569,21 @@ int slsReceiverTCPIPInterface::setup_udp(Interface &socket){
|
|||||||
// if there is a dot in eth name
|
// if there is a dot in eth name
|
||||||
if (strchr(eth, '.') != nullptr) {
|
if (strchr(eth, '.') != nullptr) {
|
||||||
strcpy(eth, "");
|
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;
|
FILE_LOG(logERROR) << mess;
|
||||||
}
|
}
|
||||||
impl()->setEthernetInterface(eth);
|
impl()->setEthernetInterface(eth);
|
||||||
if (myDetectorType == EIGER) {
|
if (myDetectorType == EIGER) {
|
||||||
impl()->setEthernetInterface2(eth);
|
impl()->setEthernetInterface2(eth);
|
||||||
}
|
}
|
||||||
//get mac address
|
// get mac address
|
||||||
if (ret != FAIL) {
|
if (ret != FAIL) {
|
||||||
temp = sls::InterfaceNameToMac(eth).str();
|
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");
|
throw RuntimeError("failed to get mac adddress to listen to\n");
|
||||||
} else {
|
} else {
|
||||||
strcpy(retvals[0],temp.c_str());
|
strcpy(retvals[0], temp.c_str());
|
||||||
FILE_LOG(logINFO) << "Receiver MAC Address: " << retvals[0];
|
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;
|
FILE_LOG(logINFO) << "Receiver UDP IP 2: " << ip2;
|
||||||
// get eth
|
// get eth
|
||||||
temp = sls::IpToInterfaceName(ip2);
|
temp = sls::IpToInterfaceName(ip2);
|
||||||
if (temp == "none"){
|
if (temp == "none") {
|
||||||
throw RuntimeError("Failed to get 2nd ethernet interface or IP");
|
throw RuntimeError("Failed to get 2nd ethernet interface or IP");
|
||||||
} else {
|
} else {
|
||||||
char eth[MAX_STR_LENGTH] = {""};
|
char eth[MAX_STR_LENGTH] = {""};
|
||||||
@ -604,27 +604,34 @@ int slsReceiverTCPIPInterface::setup_udp(Interface &socket){
|
|||||||
// if there is a dot in eth name
|
// if there is a dot in eth name
|
||||||
if (strchr(eth, '.') != nullptr) {
|
if (strchr(eth, '.') != nullptr) {
|
||||||
strcpy(eth, "");
|
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;
|
FILE_LOG(logERROR) << mess;
|
||||||
}
|
}
|
||||||
impl()->setEthernetInterface2(eth);
|
impl()->setEthernetInterface2(eth);
|
||||||
|
|
||||||
//get mac address
|
// get mac address
|
||||||
if (ret != FAIL) {
|
if (ret != FAIL) {
|
||||||
temp = sls::InterfaceNameToMac(eth).str();
|
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 2nd mac adddress to listen to");
|
throw RuntimeError(
|
||||||
|
"failed to get 2nd mac adddress to listen to");
|
||||||
FILE_LOG(logERROR) << mess;
|
FILE_LOG(logERROR) << mess;
|
||||||
} else {
|
} else {
|
||||||
strcpy(retvals[1],temp.c_str());
|
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)
|
// set the number of udp interfaces (changes number of threads and many
|
||||||
if (myDetectorType == JUNGFRAU && impl()->setNumberofUDPInterfaces(numInterfaces) == FAIL) {
|
// others)
|
||||||
|
if (myDetectorType == JUNGFRAU &&
|
||||||
|
impl()->setNumberofUDPInterfaces(numInterfaces) == FAIL) {
|
||||||
throw RuntimeError("Failed to set number of interfaces");
|
throw RuntimeError("Failed to set number of interfaces");
|
||||||
}
|
}
|
||||||
return socket.sendResult(ret, retvals, sizeof(retvals), mess);
|
return socket.sendResult(ret, retvals, sizeof(retvals), mess);
|
||||||
@ -636,7 +643,8 @@ int slsReceiverTCPIPInterface::set_timer(Interface &socket) {
|
|||||||
int64_t retval = -1;
|
int64_t retval = -1;
|
||||||
socket.receiveArg(index);
|
socket.receiveArg(index);
|
||||||
if (index[1] >= 0) {
|
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]) {
|
switch (index[0]) {
|
||||||
case ACQUISITION_TIME:
|
case ACQUISITION_TIME:
|
||||||
ret = impl()->setAcquisitionTime(index[1]);
|
ret = impl()->setAcquisitionTime(index[1]);
|
||||||
@ -657,14 +665,16 @@ int slsReceiverTCPIPInterface::set_timer(Interface &socket) {
|
|||||||
break;
|
break;
|
||||||
case ANALOG_SAMPLES:
|
case ANALOG_SAMPLES:
|
||||||
if (myDetectorType != CHIPTESTBOARD && myDetectorType != MOENCH) {
|
if (myDetectorType != CHIPTESTBOARD && myDetectorType != MOENCH) {
|
||||||
modeNotImplemented("(Analog Samples) Timer index", (int)index[0]);
|
modeNotImplemented("(Analog Samples) Timer index",
|
||||||
|
(int)index[0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
impl()->setNumberofAnalogSamples(index[1]);
|
impl()->setNumberofAnalogSamples(index[1]);
|
||||||
break;
|
break;
|
||||||
case DIGITAL_SAMPLES:
|
case DIGITAL_SAMPLES:
|
||||||
if (myDetectorType != CHIPTESTBOARD && myDetectorType != MOENCH) {
|
if (myDetectorType != CHIPTESTBOARD && myDetectorType != MOENCH) {
|
||||||
modeNotImplemented("(Digital Samples) Timer index", (int)index[0]);
|
modeNotImplemented("(Digital Samples) Timer index",
|
||||||
|
(int)index[0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
impl()->setNumberofDigitalSamples(index[1]);
|
impl()->setNumberofDigitalSamples(index[1]);
|
||||||
@ -673,47 +683,53 @@ int slsReceiverTCPIPInterface::set_timer(Interface &socket) {
|
|||||||
modeNotImplemented("Timer index", (int)index[0]);
|
modeNotImplemented("Timer index", (int)index[0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// get
|
// get
|
||||||
switch (index[0]) {
|
switch (index[0]) {
|
||||||
case ACQUISITION_TIME:
|
case ACQUISITION_TIME:
|
||||||
retval=impl()->getAcquisitionTime();
|
retval = impl()->getAcquisitionTime();
|
||||||
break;
|
break;
|
||||||
case FRAME_PERIOD:
|
case FRAME_PERIOD:
|
||||||
retval=impl()->getAcquisitionPeriod();
|
retval = impl()->getAcquisitionPeriod();
|
||||||
break;
|
break;
|
||||||
case FRAME_NUMBER:
|
case FRAME_NUMBER:
|
||||||
case CYCLES_NUMBER:
|
case CYCLES_NUMBER:
|
||||||
case STORAGE_CELL_NUMBER:
|
case STORAGE_CELL_NUMBER:
|
||||||
retval=impl()->getNumberOfFrames();
|
retval = impl()->getNumberOfFrames();
|
||||||
break;
|
break;
|
||||||
case SUBFRAME_ACQUISITION_TIME:
|
case SUBFRAME_ACQUISITION_TIME:
|
||||||
retval=impl()->getSubExpTime();
|
retval = impl()->getSubExpTime();
|
||||||
break;
|
break;
|
||||||
case SUBFRAME_DEADTIME:
|
case SUBFRAME_DEADTIME:
|
||||||
retval=(impl()->getSubPeriod() - impl()->getSubExpTime());
|
retval = (impl()->getSubPeriod() - impl()->getSubExpTime());
|
||||||
break;
|
break;
|
||||||
case ANALOG_SAMPLES:
|
case ANALOG_SAMPLES:
|
||||||
if (myDetectorType != CHIPTESTBOARD && myDetectorType != MOENCH) {
|
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);
|
throw RuntimeError(mess);
|
||||||
}
|
}
|
||||||
retval=impl()->getNumberofAnalogSamples();
|
retval = impl()->getNumberofAnalogSamples();
|
||||||
break;
|
break;
|
||||||
case DIGITAL_SAMPLES:
|
case DIGITAL_SAMPLES:
|
||||||
if (myDetectorType != CHIPTESTBOARD && myDetectorType != MOENCH) {
|
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);
|
throw RuntimeError(mess);
|
||||||
}
|
}
|
||||||
retval=impl()->getNumberofDigitalSamples();
|
retval = impl()->getNumberofDigitalSamples();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
modeNotImplemented("Timer index", (int)index[0]);
|
modeNotImplemented("Timer index", (int)index[0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
validate((int)index[1], (int)retval, std::string("set timer"), DEC);
|
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);
|
return socket.sendResult(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -738,14 +754,13 @@ int slsReceiverTCPIPInterface::set_dynamic_range(Interface &socket) {
|
|||||||
}
|
}
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
modeNotImplemented("Dynamic range", dr);
|
modeNotImplemented("Dynamic range", dr);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ret = impl()->setDynamicRange(dr);
|
ret = impl()->setDynamicRange(dr);
|
||||||
if(ret == FAIL) {
|
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();
|
int retval = impl()->getDynamicRange();
|
||||||
validate(dr, retval, std::string("set dynamic range"), DEC);
|
validate(dr, retval, std::string("set dynamic range"), DEC);
|
||||||
@ -759,7 +774,7 @@ int slsReceiverTCPIPInterface::set_streaming_frequency(Interface &socket) {
|
|||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1) << "Setting streaming frequency: " << index;
|
FILE_LOG(logDEBUG1) << "Setting streaming frequency: " << index;
|
||||||
ret = impl()->setStreamingFrequency(index);
|
ret = impl()->setStreamingFrequency(index);
|
||||||
if(ret == FAIL) {
|
if (ret == FAIL) {
|
||||||
throw RuntimeError("Could not allocate memory for listening fifo");
|
throw RuntimeError("Could not allocate memory for listening fifo");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -768,17 +783,18 @@ int slsReceiverTCPIPInterface::set_streaming_frequency(Interface &socket) {
|
|||||||
return socket.sendResult(retval);
|
return socket.sendResult(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::get_status(Interface &socket){
|
int slsReceiverTCPIPInterface::get_status(Interface &socket) {
|
||||||
auto retval = impl()->getStatus();
|
auto retval = impl()->getStatus();
|
||||||
FILE_LOG(logDEBUG1) << "Status:" << runStatusType(retval);
|
FILE_LOG(logDEBUG1) << "Status:" << runStatusType(retval);
|
||||||
return socket.sendResult(retval);
|
return socket.sendResult(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::start_receiver(Interface &socket){
|
int slsReceiverTCPIPInterface::start_receiver(Interface &socket) {
|
||||||
runStatus status = impl()->getStatus();
|
runStatus status = impl()->getStatus();
|
||||||
if (status != IDLE) {
|
if (status != IDLE) {
|
||||||
throw RuntimeError("Cannot start Receiver as it is: " +runStatusType(status));
|
throw RuntimeError("Cannot start Receiver as it is: " +
|
||||||
}else {
|
runStatusType(status));
|
||||||
|
} else {
|
||||||
FILE_LOG(logDEBUG1) << "Starting Receiver";
|
FILE_LOG(logDEBUG1) << "Starting Receiver";
|
||||||
ret = impl()->startReceiver(mess);
|
ret = impl()->startReceiver(mess);
|
||||||
if (ret == FAIL) {
|
if (ret == FAIL) {
|
||||||
@ -788,14 +804,15 @@ int slsReceiverTCPIPInterface::start_receiver(Interface &socket){
|
|||||||
return socket.sendData(OK);
|
return socket.sendData(OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::stop_receiver(Interface &socket){
|
int slsReceiverTCPIPInterface::stop_receiver(Interface &socket) {
|
||||||
if(impl()->getStatus() != IDLE) {
|
if (impl()->getStatus() != IDLE) {
|
||||||
FILE_LOG(logDEBUG1) << "Stopping Receiver";
|
FILE_LOG(logDEBUG1) << "Stopping Receiver";
|
||||||
impl()->stopReceiver();
|
impl()->stopReceiver();
|
||||||
}
|
}
|
||||||
auto s = impl()->getStatus();
|
auto s = impl()->getStatus();
|
||||||
if (s != IDLE)
|
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);
|
return socket.sendData(OK);
|
||||||
}
|
}
|
||||||
@ -849,25 +866,25 @@ int slsReceiverTCPIPInterface::set_file_index(Interface &socket) {
|
|||||||
return socket.sendResult(retval);
|
return socket.sendResult(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::get_frame_index(Interface &socket){
|
int slsReceiverTCPIPInterface::get_frame_index(Interface &socket) {
|
||||||
uint64_t retval = impl()->getAcquisitionIndex();
|
uint64_t retval = impl()->getAcquisitionIndex();
|
||||||
FILE_LOG(logDEBUG1) << "frame index:" << retval;
|
FILE_LOG(logDEBUG1) << "frame index:" << retval;
|
||||||
return socket.sendResult(retval);
|
return socket.sendResult(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::get_frames_caught(Interface &socket){
|
int slsReceiverTCPIPInterface::get_frames_caught(Interface &socket) {
|
||||||
int retval = impl()->getTotalFramesCaught();
|
int retval = impl()->getTotalFramesCaught();
|
||||||
FILE_LOG(logDEBUG1) << "frames caught:" << retval;
|
FILE_LOG(logDEBUG1) << "frames caught:" << retval;
|
||||||
return socket.sendResult(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";
|
FILE_LOG(logDEBUG1) << "Reset frames caught";
|
||||||
impl()->resetAcquisitionCount();
|
impl()->resetAcquisitionCount();
|
||||||
return socket.sendData(OK);
|
return socket.sendData(OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::enable_file_write(Interface &socket){
|
int slsReceiverTCPIPInterface::enable_file_write(Interface &socket) {
|
||||||
auto enable = socket.receive<int>();
|
auto enable = socket.receive<int>();
|
||||||
if (enable >= 0) {
|
if (enable >= 0) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
@ -880,8 +897,7 @@ int slsReceiverTCPIPInterface::enable_file_write(Interface &socket){
|
|||||||
return socket.sendResult(retval);
|
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>();
|
auto enable = socket.receive<int>();
|
||||||
if (enable >= 0) {
|
if (enable >= 0) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
@ -894,7 +910,6 @@ int slsReceiverTCPIPInterface::enable_master_file_write(Interface &socket){
|
|||||||
return socket.sendResult(retval);
|
return socket.sendResult(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::enable_overwrite(Interface &socket) {
|
int slsReceiverTCPIPInterface::enable_overwrite(Interface &socket) {
|
||||||
auto index = socket.receive<int>();
|
auto index = socket.receive<int>();
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
@ -910,14 +925,14 @@ int slsReceiverTCPIPInterface::enable_overwrite(Interface &socket) {
|
|||||||
|
|
||||||
int slsReceiverTCPIPInterface::enable_tengiga(Interface &socket) {
|
int slsReceiverTCPIPInterface::enable_tengiga(Interface &socket) {
|
||||||
auto val = socket.receive<int>();
|
auto val = socket.receive<int>();
|
||||||
if (myDetectorType != EIGER && myDetectorType != CHIPTESTBOARD && myDetectorType != MOENCH)
|
if (myDetectorType != EIGER && myDetectorType != CHIPTESTBOARD &&
|
||||||
|
myDetectorType != MOENCH)
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
|
|
||||||
if (val >= 0) {
|
if (val >= 0) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1) << "Setting 10GbE:" << val;
|
FILE_LOG(logDEBUG1) << "Setting 10GbE:" << val;
|
||||||
ret = impl()->setTenGigaEnable(val);
|
ret = impl()->setTenGigaEnable(val);
|
||||||
|
|
||||||
}
|
}
|
||||||
int retval = impl()->getTenGigaEnable();
|
int retval = impl()->getTenGigaEnable();
|
||||||
validate(val, retval, std::string("set 10GbE"), DEC);
|
validate(val, retval, std::string("set 10GbE"), DEC);
|
||||||
@ -954,7 +969,7 @@ int slsReceiverTCPIPInterface::set_activate(Interface &socket) {
|
|||||||
return socket.sendResult(retval);
|
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>();
|
auto index = socket.receive<int>();
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
@ -967,27 +982,23 @@ int slsReceiverTCPIPInterface::set_data_stream_enable(Interface &socket){
|
|||||||
return socket.sendResult(retval);
|
return socket.sendResult(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int slsReceiverTCPIPInterface::set_streaming_timer(Interface &socket) {
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_streaming_timer(Interface &socket){
|
|
||||||
auto index = socket.receive<int>();
|
auto index = socket.receive<int>();
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1) << "Setting streaming timer:" << index;
|
FILE_LOG(logDEBUG1) << "Setting streaming timer:" << index;
|
||||||
impl()->setStreamingTimer(index);
|
impl()->setStreamingTimer(index);
|
||||||
}
|
}
|
||||||
int retval=impl()->getStreamingTimer();
|
int retval = impl()->getStreamingTimer();
|
||||||
validate(index, retval, std::string("set data stream timer"), DEC);
|
validate(index, retval, std::string("set data stream timer"), DEC);
|
||||||
FILE_LOG(logDEBUG1) << "Streaming timer:" << retval;
|
FILE_LOG(logDEBUG1) << "Streaming timer:" << retval;
|
||||||
return socket.sendResult(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));
|
memset(mess, 0, sizeof(mess));
|
||||||
int args[2]{0,-1};
|
int args[2]{0, -1};
|
||||||
socket.receiveArg(args);
|
socket.receiveArg(args);
|
||||||
|
|
||||||
if (myDetectorType != EIGER)
|
if (myDetectorType != EIGER)
|
||||||
@ -996,7 +1007,7 @@ int slsReceiverTCPIPInterface::set_flipped_data(Interface &socket){
|
|||||||
if (args[1] >= 0) {
|
if (args[1] >= 0) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1) << "Setting flipped data:" << args[1];
|
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]);
|
int retval = impl()->getFlippedData(args[0]);
|
||||||
validate(args[1], retval, std::string("set flipped data"), DEC);
|
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);
|
return socket.sendResult(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_file_format(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_file_format(Interface &socket) {
|
||||||
fileFormat f = GET_FILE_FORMAT;
|
fileFormat f = GET_FILE_FORMAT;
|
||||||
socket.receiveArg(f);
|
socket.receiveArg(f);
|
||||||
@ -1036,14 +1045,14 @@ int slsReceiverTCPIPInterface::set_detector_posid(Interface &socket) {
|
|||||||
int slsReceiverTCPIPInterface::set_multi_detector_size(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_multi_detector_size(Interface &socket) {
|
||||||
int arg[]{-1, -1};
|
int arg[]{-1, -1};
|
||||||
socket.receiveArg(arg);
|
socket.receiveArg(arg);
|
||||||
if((arg[0] > 0) && (arg[1] > 0)) {
|
if ((arg[0] > 0) && (arg[1] > 0)) {
|
||||||
VerifyIdle(socket);
|
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);
|
impl()->setMultiDetectorSize(arg);
|
||||||
|
|
||||||
}
|
}
|
||||||
int* temp = impl()->getMultiDetectorSize(); //TODO! return by value!
|
int *temp = impl()->getMultiDetectorSize(); // TODO! return by value!
|
||||||
int retval = temp[0]*temp[1];
|
int retval = temp[0] * temp[1];
|
||||||
FILE_LOG(logDEBUG1) << "Multi Detector Size:" << retval;
|
FILE_LOG(logDEBUG1) << "Multi Detector Size:" << retval;
|
||||||
return socket.sendResult(retval);
|
return socket.sendResult(retval);
|
||||||
}
|
}
|
||||||
@ -1102,10 +1111,11 @@ int slsReceiverTCPIPInterface::enable_gap_pixels(Interface &socket) {
|
|||||||
return socket.sendResult(retval);
|
return socket.sendResult(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::restream_stop(Interface &socket){
|
int slsReceiverTCPIPInterface::restream_stop(Interface &socket) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
if (impl()->getDataStreamEnable() == false) {
|
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 {
|
} else {
|
||||||
FILE_LOG(logDEBUG1) << "Restreaming stop";
|
FILE_LOG(logDEBUG1) << "Restreaming stop";
|
||||||
ret = impl()->restreamStop();
|
ret = impl()->restreamStop();
|
||||||
@ -1141,17 +1151,23 @@ int slsReceiverTCPIPInterface::set_udp_socket_buffer_size(Interface &socket) {
|
|||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1) << "Setting UDP Socket Buffer size: " << index;
|
FILE_LOG(logDEBUG1) << "Setting UDP Socket Buffer size: " << index;
|
||||||
if (impl()->setUDPSocketBufferSize(index) == FAIL) {
|
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();
|
int64_t retval = impl()->getUDPSocketBufferSize();
|
||||||
if (index != 0)
|
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;
|
FILE_LOG(logDEBUG1) << "UDP Socket Buffer Size:" << retval;
|
||||||
return socket.sendResult(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();
|
auto size = impl()->getActualUDPSocketBufferSize();
|
||||||
FILE_LOG(logDEBUG1) << "Actual UDP socket size :" << size;
|
FILE_LOG(logDEBUG1) << "Actual UDP socket size :" << size;
|
||||||
return socket.sendResult(size);
|
return socket.sendResult(size);
|
||||||
@ -1172,7 +1188,8 @@ int slsReceiverTCPIPInterface::set_frames_per_file(Interface &socket) {
|
|||||||
|
|
||||||
int slsReceiverTCPIPInterface::check_version_compatibility(Interface &socket) {
|
int slsReceiverTCPIPInterface::check_version_compatibility(Interface &socket) {
|
||||||
auto arg = socket.receive<int64_t>();
|
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 client_requiredVersion = arg;
|
||||||
int64_t rx_apiVersion = APIRECEIVER;
|
int64_t rx_apiVersion = APIRECEIVER;
|
||||||
int64_t rx_version = getReceiverVersion();
|
int64_t rx_version = getReceiverVersion();
|
||||||
@ -1180,23 +1197,26 @@ int slsReceiverTCPIPInterface::check_version_compatibility(Interface &socket) {
|
|||||||
if (rx_apiVersion > client_requiredVersion) {
|
if (rx_apiVersion > client_requiredVersion) {
|
||||||
// old client
|
// old client
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
sprintf(mess,"This client is incompatible.\n"
|
sprintf(mess,
|
||||||
"Client's receiver API Version: (0x%llx). Receiver API Version: (0x%llx).\n"
|
"This client is incompatible.\n"
|
||||||
|
"Client's receiver API Version: (0x%llx). Receiver API "
|
||||||
|
"Version: (0x%llx).\n"
|
||||||
"Incompatible, update client!\n",
|
"Incompatible, update client!\n",
|
||||||
(long long unsigned int)client_requiredVersion,
|
(long long unsigned int)client_requiredVersion,
|
||||||
(long long unsigned int)rx_apiVersion);
|
(long long unsigned int)rx_apiVersion);
|
||||||
throw RuntimeError(mess);
|
throw RuntimeError(mess);
|
||||||
}else if (client_requiredVersion > rx_version) {
|
} else if (client_requiredVersion > rx_version) {
|
||||||
// old software
|
// old software
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
sprintf(mess,"This receiver is incompatible.\n"
|
sprintf(mess,
|
||||||
"Receiver Version: (0x%llx). Client's receiver API Version: (0x%llx).\n"
|
"This receiver is incompatible.\n"
|
||||||
|
"Receiver Version: (0x%llx). Client's receiver API Version: "
|
||||||
|
"(0x%llx).\n"
|
||||||
"Incompatible, update receiver!\n",
|
"Incompatible, update receiver!\n",
|
||||||
(long long unsigned int)rx_version,
|
(long long unsigned int)rx_version,
|
||||||
(long long unsigned int)client_requiredVersion);
|
(long long unsigned int)client_requiredVersion);
|
||||||
throw RuntimeError(mess);
|
throw RuntimeError(mess);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
FILE_LOG(logINFO) << "Compatibility with Client: Successful";
|
FILE_LOG(logINFO) << "Compatibility with Client: Successful";
|
||||||
}
|
}
|
||||||
return socket.sendData(OK);
|
return socket.sendData(OK);
|
||||||
@ -1229,7 +1249,8 @@ int slsReceiverTCPIPInterface::set_padding_enable(Interface &socket) {
|
|||||||
return socket.sendResult(retval);
|
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>();
|
auto enable = socket.receive<int>();
|
||||||
if (myDetectorType != EIGER)
|
if (myDetectorType != EIGER)
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
@ -1240,7 +1261,8 @@ int slsReceiverTCPIPInterface::set_deactivated_padding_enable(Interface &socket)
|
|||||||
impl()->setDeactivatedPadding(enable > 0 ? true : false);
|
impl()->setDeactivatedPadding(enable > 0 ? true : false);
|
||||||
}
|
}
|
||||||
auto retval = static_cast<int>(impl()->getDeactivatedPadding());
|
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;
|
FILE_LOG(logDEBUG1) << "Deactivated Padding Enable: " << retval;
|
||||||
return socket.sendResult(retval);
|
return socket.sendResult(retval);
|
||||||
}
|
}
|
||||||
@ -1248,7 +1270,8 @@ int slsReceiverTCPIPInterface::set_deactivated_padding_enable(Interface &socket)
|
|||||||
int slsReceiverTCPIPInterface::set_readout_flags(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_readout_flags(Interface &socket) {
|
||||||
auto arg = socket.receive<readOutFlags>();
|
auto arg = socket.receive<readOutFlags>();
|
||||||
|
|
||||||
if (myDetectorType == JUNGFRAU || myDetectorType == GOTTHARD || myDetectorType == MOENCH)
|
if (myDetectorType == JUNGFRAU || myDetectorType == GOTTHARD ||
|
||||||
|
myDetectorType == MOENCH)
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
|
|
||||||
if (arg >= 0) {
|
if (arg >= 0) {
|
||||||
@ -1257,7 +1280,8 @@ int slsReceiverTCPIPInterface::set_readout_flags(Interface &socket) {
|
|||||||
ret = impl()->setReadOutFlags(arg);
|
ret = impl()->setReadOutFlags(arg);
|
||||||
}
|
}
|
||||||
auto retval = impl()->getReadOutFlags();
|
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;
|
FILE_LOG(logDEBUG1) << "Readout flags: " << retval;
|
||||||
return socket.sendResult(retval);
|
return socket.sendResult(retval);
|
||||||
}
|
}
|
||||||
@ -1269,7 +1293,8 @@ int slsReceiverTCPIPInterface::set_adc_mask(Interface &socket) {
|
|||||||
impl()->setADCEnableMask(arg);
|
impl()->setADCEnableMask(arg);
|
||||||
auto retval = impl()->getADCEnableMask();
|
auto retval = impl()->getADCEnableMask();
|
||||||
if (retval != arg) {
|
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);
|
throw RuntimeError(mess);
|
||||||
}
|
}
|
||||||
FILE_LOG(logDEBUG1) << "ADC enable mask retval: " << retval;
|
FILE_LOG(logDEBUG1) << "ADC enable mask retval: " << retval;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user