mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 18:17:59 +02:00
receiver compiles
This commit is contained in:
@ -1,801 +0,0 @@
|
||||
#pragma once
|
||||
/***********************************************
|
||||
* @file UDPInterface.h
|
||||
* @short Base class with all the functions for the UDP inteface of the receiver
|
||||
***********************************************/
|
||||
/**
|
||||
* \mainpage Base class with all the functions for the UDP inteface of the receiver
|
||||
*/
|
||||
|
||||
/**
|
||||
* @short Base class with all the functions for the UDP inteface of the receiver
|
||||
*/
|
||||
|
||||
#include "sls_receiver_defs.h"
|
||||
#include "receiver_defs.h"
|
||||
#include "utilities.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <exception>
|
||||
#include <vector>
|
||||
|
||||
class UDPInterface {
|
||||
|
||||
/* abstract class that defines the UDP interface of an sls detector data receiver.
|
||||
*
|
||||
* Use the factory method UDPInterface::create() to get an instance:
|
||||
*
|
||||
* UDPInterface *udp_interface = UDPInterface::create()
|
||||
*
|
||||
* Sequence of Calls from client (upon setting receiver)
|
||||
* -setDetectorType
|
||||
* -setMultiDetectorSize
|
||||
* -setDetectorPositionId
|
||||
* -initialize
|
||||
* -setUDPPortNumber,setUDPPortNumber2,setEthernetInterface
|
||||
* -setFilePath
|
||||
* -setFileName
|
||||
* -setFileIndex
|
||||
* -setFileFormat
|
||||
* -setFileWriteEnable
|
||||
* -setOverwriteEnable
|
||||
* -setAcquisitionPeriod
|
||||
* -setNumberOfFrames
|
||||
* -setAcquisitionTime
|
||||
* -setSubExpTime (if eiger)
|
||||
* -setNumberofSamples (if chip test board)
|
||||
* -setDynamicRange
|
||||
* -setFlippedData (if eiger)
|
||||
* -setActivate (if eiger)
|
||||
* -setDeactivatedPadding (if eiger)
|
||||
* -setTenGigaEnable (if eiger)
|
||||
* -setGapPixelsEnable
|
||||
* -setStreamingPort
|
||||
* -setStreamingSourceIP
|
||||
* -setAdditionalJsonHeader
|
||||
* -setDataStreamEnable
|
||||
* -setROI
|
||||
*
|
||||
*
|
||||
*
|
||||
* supported sequence of method-calls:
|
||||
*
|
||||
* initialize() : once and only once after create()
|
||||
*
|
||||
* get*() : anytime after initialize(), multiples times
|
||||
*
|
||||
* set*() : anytime after initialize(), multiple times
|
||||
*
|
||||
* startReceiver(): anytime after initialize(). Will fail in TCPIP itself if state already is 'running':
|
||||
*
|
||||
* Only startReceiver() does change the data receiver configuration, it does pass the whole configuration cache to the data receiver.
|
||||
*
|
||||
* abort(), //FIXME: needed?
|
||||
*
|
||||
* stopReceiver() : anytime after initialize(). Will do nothing if state already is idle.
|
||||
* Otherwise, sets status to transmitting when shutting down sockets
|
||||
* then to run_finished when all data obtained
|
||||
* then to idle when returning from this function
|
||||
*
|
||||
*
|
||||
* getStatus() returns the actual state of the data receiver - idle, running or error, enum defined in include/sls_receiver_defs.h
|
||||
*
|
||||
*
|
||||
*
|
||||
* get*() and set*() methods access the local cache of configuration values only and *do not* modify the data receiver settings.
|
||||
*
|
||||
* set methods return nothing, use get methods to validate a set method success
|
||||
*
|
||||
* get-methods that return a char array (char *) allocate a new array at each call. The caller is responsible to free the allocated space:
|
||||
*
|
||||
* char *c = receiver->getFileName();
|
||||
* Or
|
||||
* FIXME: so that the pointers are not shared external to the class, do the following way in the calling method?
|
||||
* char *c = new char[MAX_STR_LENGTH];
|
||||
* strcpy(c,receiver->getFileName());
|
||||
* ....
|
||||
*
|
||||
* delete[] c;
|
||||
*
|
||||
* All pointers passed in externally will be allocated and freed by the calling function
|
||||
*
|
||||
* OK and FAIL are defined in include/sls_receiver_defs.h for functions implementing behavior
|
||||
*
|
||||
*/
|
||||
|
||||
public:
|
||||
|
||||
/*************************************************************************
|
||||
* Constructor & Destructor **********************************************
|
||||
* They access local cache of configuration or detector parameters *******
|
||||
*************************************************************************/
|
||||
/**
|
||||
* Constructor
|
||||
* Only non virtual function implemented in this class
|
||||
* Factory create method to create a standard or custom object
|
||||
* @param [in] receiver_type type can be standard or custom (must be derived from base class)
|
||||
* @return a UDPInterface reference to object depending on receiver type
|
||||
*/
|
||||
static UDPInterface *create(std::string receiver_type = "standard");
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~UDPInterface() {};
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Getters ***************************************************************
|
||||
* They access local cache of configuration or detector parameters *******
|
||||
*************************************************************************/
|
||||
|
||||
//**initial/detector parameters***
|
||||
|
||||
/*
|
||||
* Get multi detector size
|
||||
* @return pointer to array of multi detector size in every dimension
|
||||
*/
|
||||
virtual int* getMultiDetectorSize() const = 0;
|
||||
|
||||
/*
|
||||
* Get detector position id
|
||||
* @return detector position id
|
||||
*/
|
||||
virtual int getDetectorPositionId() const = 0;
|
||||
|
||||
/*
|
||||
* Get detector hostname
|
||||
* @return hostname or NULL if uninitialized, must be released by calling function (max of 1000 characters)
|
||||
*/
|
||||
virtual char *getDetectorHostname() const = 0;
|
||||
|
||||
/*
|
||||
* Get flipped data across 'axis'
|
||||
* @return if data is flipped across 'axis'
|
||||
*/
|
||||
virtual int getFlippedData(int axis=0) const = 0;
|
||||
|
||||
/**
|
||||
* Get Gap Pixels Enable (eiger specific)
|
||||
* @return true if gap pixels enabled, else false
|
||||
*/
|
||||
virtual bool getGapPixelsEnable() const = 0;
|
||||
|
||||
|
||||
//***file parameters***
|
||||
/**
|
||||
* Get File Format
|
||||
* @return file format
|
||||
*/
|
||||
virtual slsReceiverDefs::fileFormat getFileFormat() const = 0;
|
||||
|
||||
/**
|
||||
* Get File Name Prefix (without frame index, file index and extension (_d0_f000000000000_8.raw))
|
||||
* @return NULL or pointer to file name prefix, must be released by calling function (max of 1000 characters)
|
||||
*/
|
||||
virtual char *getFileName() const = 0;
|
||||
|
||||
/**
|
||||
* Get File Path
|
||||
* @return NULL or pointer to file path, must be released by calling function (max of 1000 characters)
|
||||
*/
|
||||
virtual char *getFilePath() const = 0;
|
||||
|
||||
/**
|
||||
* Get File Index
|
||||
* @return file index of acquisition
|
||||
*/
|
||||
virtual uint64_t getFileIndex() const = 0;
|
||||
|
||||
/**
|
||||
* Get Frames per File (0 means infinite)
|
||||
* @return Frames per File
|
||||
*/
|
||||
virtual uint32_t getFramesPerFile() const = 0;
|
||||
|
||||
/**
|
||||
* Get Frame Discard Policy
|
||||
* @return Frame Discard Policy
|
||||
*/
|
||||
virtual slsReceiverDefs::frameDiscardPolicy getFrameDiscardPolicy() const = 0;
|
||||
|
||||
/**
|
||||
* Get Partial Frame Padding Enable
|
||||
* @return Partial Frame Padding Enable
|
||||
*/
|
||||
virtual bool getFramePaddingEnable() const = 0;
|
||||
|
||||
/**
|
||||
* Get Scan Tag
|
||||
* @return scan tag //FIXME: needed? (unsigned integer?)
|
||||
*/
|
||||
virtual int getScanTag() const = 0;
|
||||
|
||||
/**
|
||||
* Get File Write Enable
|
||||
* @return true if file write enabled, else false
|
||||
*/
|
||||
virtual bool getFileWriteEnable() const = 0;
|
||||
|
||||
/**
|
||||
* Get File Over Write Enable
|
||||
* @return true if file over write enabled, else false
|
||||
*/
|
||||
virtual bool getOverwriteEnable() const = 0;
|
||||
|
||||
/**
|
||||
* Get data compression, by saving only hits (so far implemented only for Moench and Gotthard)
|
||||
* @return true if data compression enabled, else false
|
||||
*/
|
||||
virtual bool getDataCompressionEnable() const = 0;
|
||||
|
||||
|
||||
//***acquisition count parameters***
|
||||
/**
|
||||
* Get Total Frames Caught for an entire acquisition (including all scans)
|
||||
* @return total number of frames caught for entire acquisition
|
||||
*/
|
||||
virtual uint64_t getTotalFramesCaught() const = 0;
|
||||
|
||||
/**
|
||||
* Get Frames Caught for each real time acquisition (eg. for each scan)
|
||||
* @return number of frames caught for each scan
|
||||
*/
|
||||
virtual uint64_t getFramesCaught() const = 0;
|
||||
|
||||
/**
|
||||
* Get Current Frame Index for an entire acquisition (including all scans)
|
||||
* @return -1 if no frames have been caught, else current frame index (represents all scans too) or -1 if no packets caught
|
||||
*/
|
||||
virtual int64_t getAcquisitionIndex() const = 0;
|
||||
|
||||
|
||||
//***connection parameters***
|
||||
/**
|
||||
* Get UDP Port Number
|
||||
* @return udp port number
|
||||
*/
|
||||
virtual uint32_t getUDPPortNumber() const = 0;
|
||||
|
||||
/**
|
||||
* Get Second UDP Port Number (eiger specific)
|
||||
* @return second udp port number
|
||||
*/
|
||||
virtual uint32_t getUDPPortNumber2() const = 0;
|
||||
|
||||
/**
|
||||
* Get Ehernet Interface
|
||||
* @return ethernet interface. eg. eth0 (max of 1000 characters)
|
||||
*/
|
||||
virtual char *getEthernetInterface() const = 0;
|
||||
|
||||
|
||||
//***acquisition parameters***
|
||||
/**
|
||||
* Get ROI
|
||||
* @return index of adc enabled, else -1 if all enabled
|
||||
*/
|
||||
virtual std::vector<slsReceiverDefs::ROI> getROI() const = 0;
|
||||
|
||||
/**
|
||||
* Get the Frequency of Frames Sent to GUI
|
||||
* @return 0 for random frame requests, n for nth frame frequency
|
||||
*/
|
||||
virtual uint32_t getFrameToGuiFrequency() const = 0;
|
||||
|
||||
/**
|
||||
* Gets the timer between frames streamed when frequency is set to 0
|
||||
* @return timer between frames streamed
|
||||
*/
|
||||
virtual uint32_t getFrameToGuiTimer() const = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Get the data stream enable
|
||||
* @return data stream enable
|
||||
*/
|
||||
virtual bool getDataStreamEnable() const = 0;
|
||||
|
||||
/**
|
||||
* Get Acquisition Period
|
||||
* @return acquisition period
|
||||
*/
|
||||
virtual uint64_t getAcquisitionPeriod() const = 0;
|
||||
|
||||
/**
|
||||
* Get Acquisition Time
|
||||
* @return acquisition time
|
||||
*/
|
||||
virtual uint64_t getAcquisitionTime() const = 0;
|
||||
|
||||
/**
|
||||
* Get Sub Exposure Time
|
||||
* @return Sub Exposure Time
|
||||
*/
|
||||
virtual uint64_t getSubExpTime() const = 0;
|
||||
|
||||
/**
|
||||
* Get Sub Period
|
||||
* @return Sub Period
|
||||
*/
|
||||
virtual uint64_t getSubPeriod() const = 0;
|
||||
|
||||
/*
|
||||
* 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: (for Leo? Not implemented)
|
||||
* @return number of samples expected
|
||||
*/
|
||||
virtual uint64_t getNumberOfFrames() const = 0;
|
||||
|
||||
/*
|
||||
* Get Number of Samples expected by receiver from detector (for chip test board only)
|
||||
* @return number of samples expected
|
||||
*/
|
||||
virtual uint64_t getNumberofSamples() const = 0;
|
||||
|
||||
/**
|
||||
* Get Dynamic Range or Number of Bits Per Pixel
|
||||
* @return dynamic range that is 4, 8, 16 or 32
|
||||
*/
|
||||
virtual uint32_t getDynamicRange() const = 0;
|
||||
|
||||
/**
|
||||
* Get Ten Giga Enable
|
||||
* @return true if 10Giga enabled, else false (1G enabled)
|
||||
*/
|
||||
virtual bool getTenGigaEnable() const = 0;
|
||||
|
||||
/**
|
||||
* Get Fifo Depth
|
||||
* @return fifo depth
|
||||
*/
|
||||
virtual uint32_t getFifoDepth() const = 0;
|
||||
|
||||
//***receiver status***
|
||||
/**
|
||||
* Get Listening Status of Receiver
|
||||
* @return can be idle, listening or error depending on if the receiver is listening or not
|
||||
*/
|
||||
virtual slsReceiverDefs::runStatus getStatus() const = 0;
|
||||
|
||||
/** (not saved in client shared memory)
|
||||
* Get Silent Mode
|
||||
* @return silent mode
|
||||
*/
|
||||
virtual bool getSilentMode() const = 0;
|
||||
|
||||
/**
|
||||
* Get activate
|
||||
* If deactivated, receiver will create dummy data if deactivated padding is enabled
|
||||
* (as it will receive nothing from detector)
|
||||
* @return false for deactivated, true for activated
|
||||
*/
|
||||
virtual bool getActivate() const = 0;
|
||||
|
||||
/**
|
||||
* Get deactivated padding enable
|
||||
* If enabled, receiver will create dummy packets (0xFF), else it will create nothing
|
||||
* (as it will receive nothing from detector)
|
||||
* @return false for disabled, true for enabled
|
||||
*/
|
||||
virtual bool getDeactivatedPadding() const = 0;
|
||||
|
||||
/**
|
||||
* Get Streaming Port
|
||||
* @return streaming port
|
||||
*/
|
||||
virtual uint32_t getStreamingPort() const = 0;
|
||||
|
||||
/**
|
||||
* Get streaming source ip
|
||||
* @return streaming source ip
|
||||
*/
|
||||
virtual char *getStreamingSourceIP() const = 0;
|
||||
|
||||
/**
|
||||
* Get additional json header
|
||||
* @return additional json header
|
||||
*/
|
||||
virtual char *getAdditionalJsonHeader() const = 0;
|
||||
|
||||
|
||||
/** (not saved in client shared memory)
|
||||
* Get UDP Socket Buffer Size
|
||||
* @return UDP Socket Buffer Size
|
||||
*/
|
||||
virtual uint32_t getUDPSocketBufferSize() const = 0;
|
||||
|
||||
/** (not saved in client shared memory)
|
||||
* Get actual UDP Socket Buffer Size
|
||||
* @return actual UDP Socket Buffer Size
|
||||
*/
|
||||
virtual uint32_t getActualUDPSocketBufferSize() const = 0;
|
||||
|
||||
/*************************************************************************
|
||||
* Setters ***************************************************************
|
||||
* They modify the local cache of configuration or detector parameters ***
|
||||
*************************************************************************/
|
||||
|
||||
//**initial parameters***
|
||||
/**
|
||||
* Configure command line parameters
|
||||
* @param config_map mapping of config parameters passed from command line arguments
|
||||
*/
|
||||
virtual void configure(std::map<std::string, std::string> config_map) = 0;
|
||||
|
||||
/*
|
||||
* Set multi detector size
|
||||
* @param pointer to array of multi detector size in every dimension
|
||||
*/
|
||||
virtual void setMultiDetectorSize(const int* size) = 0;
|
||||
|
||||
/*
|
||||
* Get flipped data across 'axis'
|
||||
* @return if data is flipped across 'axis'
|
||||
*/
|
||||
virtual void setFlippedData(int axis=0, int enable=-1) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Set Gap Pixels Enable (eiger specific)
|
||||
* @param b true for gap pixels enable, else false
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
virtual int setGapPixelsEnable(const bool b) = 0;
|
||||
|
||||
|
||||
//***file parameters***
|
||||
/**
|
||||
* Set File Format
|
||||
* @param f fileformat binary or hdf5
|
||||
*/
|
||||
virtual void setFileFormat(slsReceiverDefs::fileFormat f) = 0;
|
||||
|
||||
/**
|
||||
* Set File Name Prefix (without frame index, file index and extension (_d0_f000000000000_8.raw))
|
||||
* Does not check for file existence since it is created only at startReceiver
|
||||
* @param c file name (max of 1000 characters)
|
||||
*/
|
||||
virtual void setFileName(const char c[]) = 0;
|
||||
|
||||
/**
|
||||
* Set File Path
|
||||
* Checks for file directory existence before setting file path
|
||||
* @param c file path (max of 1000 characters)
|
||||
*/
|
||||
virtual void setFilePath(const char c[]) = 0;
|
||||
|
||||
/**
|
||||
* Set File Index of acquisition
|
||||
* @param i file index of acquisition
|
||||
*/
|
||||
virtual void setFileIndex(const uint64_t i) = 0;
|
||||
|
||||
/**
|
||||
* Set Frames per File (0 means infinite)
|
||||
* @param i Frames per File
|
||||
*/
|
||||
virtual void setFramesPerFile(const uint32_t i) = 0;
|
||||
|
||||
/**
|
||||
* Set Frame Discard Policy
|
||||
* @param i Frame Discard Policy
|
||||
*/
|
||||
virtual void setFrameDiscardPolicy(const slsReceiverDefs::frameDiscardPolicy i) = 0;
|
||||
|
||||
/**
|
||||
* Set Partial Frame Padding Enable
|
||||
* @param i Partial Frame Padding Enable
|
||||
*/
|
||||
virtual void setFramePaddingEnable(const bool i) = 0;
|
||||
|
||||
/**
|
||||
* Set Scan Tag
|
||||
* @param i scan tag //FIXME: needed? (unsigned integer?)
|
||||
*/
|
||||
virtual void setScanTag(const int i) = 0;
|
||||
|
||||
/**
|
||||
* Set File Write Enable
|
||||
* @param b true for file write enable, else false
|
||||
*/
|
||||
virtual void setFileWriteEnable(const bool b) = 0;
|
||||
|
||||
/**
|
||||
* Set File Overwrite Enable
|
||||
* @param b true for file overwrite enable, else false
|
||||
*/
|
||||
virtual void setOverwriteEnable(const bool b) = 0;
|
||||
|
||||
/**
|
||||
* Set data compression, by saving only hits (so far implemented only for Moench and Gotthard)
|
||||
* @param b true for data compression enable, else false
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
virtual int setDataCompressionEnable(const bool b) = 0;
|
||||
|
||||
//***connection parameters***
|
||||
/**
|
||||
* Set UDP Port Number
|
||||
* @param i udp port number
|
||||
*/
|
||||
virtual void setUDPPortNumber(const uint32_t i) = 0;
|
||||
|
||||
/**
|
||||
* Set Second UDP Port Number (eiger specific)
|
||||
* @return second udp port number
|
||||
*/
|
||||
virtual void setUDPPortNumber2(const uint32_t i) = 0;
|
||||
|
||||
/**
|
||||
* Set Ethernet Interface to listen to
|
||||
* @param c ethernet inerface eg. eth0 (max of 1000 characters)
|
||||
*/
|
||||
virtual void setEthernetInterface(const char* c) = 0;
|
||||
|
||||
|
||||
//***acquisition parameters***
|
||||
/**
|
||||
* Set ROI
|
||||
* @param i ROI
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
virtual int setROI(const std::vector<slsReceiverDefs::ROI> i) = 0;
|
||||
|
||||
/**
|
||||
* Set the Frequency of Frames Sent to GUI
|
||||
* @param freq 0 for random frame requests, n for nth frame frequency
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
virtual int setFrameToGuiFrequency(const uint32_t freq) = 0;
|
||||
|
||||
/**
|
||||
* Sets the timer between frames streamed when frequency is set to 0
|
||||
* @param time_in_ms timer between frames streamed
|
||||
*/
|
||||
virtual void setFrameToGuiTimer(const uint32_t time_in_ms) = 0;
|
||||
|
||||
/**
|
||||
* Set the data stream enable
|
||||
* @param enable data stream enable
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
virtual int setDataStreamEnable(const bool enable) = 0;
|
||||
|
||||
/**
|
||||
* Set Acquisition Period
|
||||
* @param i acquisition period
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
virtual int setAcquisitionPeriod(const uint64_t i) = 0;
|
||||
|
||||
/**
|
||||
* Set Acquisition Time
|
||||
* @param i acquisition time
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
virtual int setAcquisitionTime(const uint64_t i) = 0;
|
||||
|
||||
/**
|
||||
* Set Sub Exposure Time
|
||||
* @param i Sub Exposure Time
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
virtual void setSubExpTime(const uint64_t i) = 0;
|
||||
|
||||
/**
|
||||
* Set Sub Period
|
||||
* @param i Period
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
virtual void setSubPeriod(const uint64_t i) = 0;
|
||||
|
||||
/**
|
||||
* 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 FIXME: (for Leo? Not implemented)
|
||||
* @param i number of frames expected
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
virtual int setNumberOfFrames(const uint64_t i) = 0;
|
||||
|
||||
/**
|
||||
* Set Number of Samples expected by receiver from detector
|
||||
* @param i number of Samples expected
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
virtual int setNumberofSamples(const uint64_t i) = 0;
|
||||
|
||||
/**
|
||||
* Set Dynamic Range or Number of Bits Per Pixel
|
||||
* @param i dynamic range that is 4, 8, 16 or 32
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
virtual int setDynamicRange(const uint32_t i) = 0;
|
||||
|
||||
/**
|
||||
* Set Ten Giga Enable
|
||||
* @param b true if 10Giga enabled, else false (1G enabled)
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
virtual int setTenGigaEnable(const bool b) = 0;
|
||||
|
||||
/**
|
||||
* Set Fifo Depth
|
||||
* @param i fifo depth value
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
virtual int setFifoDepth(const uint32_t i) = 0;
|
||||
|
||||
|
||||
//***receiver parameters***
|
||||
/**
|
||||
* Set Silent Mode
|
||||
* @param i silent mode. true sets, false unsets
|
||||
*/
|
||||
virtual void setSilentMode(const bool i) = 0;
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Behavioral functions***************************************************
|
||||
* They may modify the status of the receiver ****************************
|
||||
*************************************************************************/
|
||||
|
||||
|
||||
//***initial functions***
|
||||
/**
|
||||
* Set receiver type (and corresponding detector variables in derived STANDARD class)
|
||||
* It is the first function called by the client when connecting to receiver
|
||||
* @param d detector type
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
virtual int setDetectorType(const slsReceiverDefs::detectorType d) = 0;
|
||||
|
||||
/**
|
||||
* Set detector position id
|
||||
* @param i position id
|
||||
*/
|
||||
virtual void setDetectorPositionId(const int i) = 0;
|
||||
|
||||
/**
|
||||
* Sets detector hostname
|
||||
* It is second function called by the client when connecting to receiver.
|
||||
* you can call this function only once.
|
||||
* @param c detector hostname
|
||||
*/
|
||||
virtual void initialize(const char *c) = 0;
|
||||
|
||||
|
||||
//***acquisition functions***
|
||||
/**
|
||||
* Reset acquisition parameters such as total frames caught for an entire acquisition (including all scans)
|
||||
*/
|
||||
virtual void resetAcquisitionCount() = 0;
|
||||
|
||||
/**
|
||||
* Start Listening for Packets by activating all configuration settings to receiver
|
||||
* @param c error message if FAIL
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
virtual int startReceiver(char *c=NULL) = 0;
|
||||
|
||||
/**
|
||||
* Stop Listening for Packets
|
||||
* Calls startReadout(), which stops listening and sets status to Transmitting
|
||||
* When it has read every frame in buffer,it returns with the status Run_Finished
|
||||
*/
|
||||
virtual void stopReceiver() = 0;
|
||||
|
||||
/**
|
||||
* Stop Listening to Packets
|
||||
* and sets status to Transmitting
|
||||
*/
|
||||
virtual void startReadout() = 0;
|
||||
|
||||
/**
|
||||
* Shuts down and deletes UDP Sockets
|
||||
*/
|
||||
virtual void shutDownUDPSockets() = 0;
|
||||
|
||||
/**
|
||||
* abort acquisition with minimum damage: close open files, cleanup.
|
||||
* does nothing if state already is 'idle'
|
||||
*/
|
||||
virtual void abort() = 0; //FIXME: needed, isnt stopReceiver enough?
|
||||
|
||||
/**
|
||||
* Activate / Deactivate Receiver
|
||||
* If deactivated, receiver will create dummy data if deactivated padding is enabled
|
||||
* (as it will receive nothing from detector)
|
||||
* @param enable enable
|
||||
* @return false for disabled, true for enabled
|
||||
*/
|
||||
virtual bool setActivate(const bool enable) = 0;
|
||||
|
||||
/**
|
||||
* Set deactivated padding enable
|
||||
* If enabled, receiver will create dummy packets (0xFF), else it will create nothing
|
||||
* (as it will receive nothing from detector)
|
||||
* @param enable enable
|
||||
* @return false for disabled, true for enabled
|
||||
*/
|
||||
virtual bool setDeactivatedPadding(const bool enable) = 0;
|
||||
|
||||
/**
|
||||
* Set streaming port
|
||||
* @param i streaming port
|
||||
*/
|
||||
virtual void setStreamingPort(const uint32_t i) = 0;
|
||||
|
||||
/**
|
||||
* Set streaming source ip
|
||||
* @param c streaming source ip
|
||||
*/
|
||||
virtual void setStreamingSourceIP(const char* c) = 0;
|
||||
|
||||
/**
|
||||
* Set additional json header
|
||||
*/
|
||||
virtual void setAdditionalJsonHeader(const char* c) = 0;
|
||||
|
||||
/** (not saved in client shared memory)
|
||||
* Set UDP Socket Buffer Size
|
||||
* @param s UDP Socket Buffer Size
|
||||
* @return OK or FAIL if dummy socket could be created
|
||||
*/
|
||||
virtual int setUDPSocketBufferSize(const uint32_t s) = 0;
|
||||
|
||||
/*
|
||||
* Restream stop dummy packet from receiver
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
virtual int restreamStop() = 0;
|
||||
|
||||
|
||||
//***callback functions***
|
||||
/**
|
||||
* Call back for start acquisition
|
||||
* callback arguments are
|
||||
* filepath
|
||||
* filename
|
||||
* fileindex
|
||||
* datasize
|
||||
*
|
||||
* return value is insignificant at the moment
|
||||
* we write depending on file write enable
|
||||
* users get data to write depending on call backs registered
|
||||
*/
|
||||
virtual void registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg) = 0;
|
||||
|
||||
/**
|
||||
* Call back for acquisition finished
|
||||
* callback argument is
|
||||
* total frames caught
|
||||
*/
|
||||
virtual void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg) = 0;
|
||||
|
||||
/**
|
||||
* Call back for raw data
|
||||
* args to raw data ready callback are
|
||||
* sls_receiver_header frame metadata
|
||||
* dataPointer is the pointer to the data
|
||||
* dataSize in bytes is the size of the data in bytes.
|
||||
*/
|
||||
virtual void registerCallBackRawDataReady(void (*func)(char* ,
|
||||
char*, uint32_t, void*),void *arg) = 0;
|
||||
|
||||
/**
|
||||
* Call back for raw data (modified)
|
||||
* args to raw data ready callback are
|
||||
* sls_receiver_header frame metadata
|
||||
* dataPointer is the pointer to the data
|
||||
* revDatasize is the reference of data size in bytes. Can be modified to the new size to be written/streamed. (only smaller value).
|
||||
*/
|
||||
virtual void registerCallBackRawDataModifyReady(void (*func)(char* ,
|
||||
char*, uint32_t &,void*),void *arg) = 0;
|
||||
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
};
|
@ -1,282 +0,0 @@
|
||||
#pragma once
|
||||
/********************************************//**
|
||||
* @file UDPBaseImplementation.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.
|
||||
*/
|
||||
#include "UDPBaseImplementation.h"
|
||||
|
||||
class GeneralData;
|
||||
class Listener;
|
||||
class DataProcessor;
|
||||
class DataStreamer;
|
||||
class Fifo;
|
||||
|
||||
|
||||
|
||||
class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBaseImplementation {
|
||||
public:
|
||||
|
||||
|
||||
//*** cosntructor & destructor ***
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
UDPStandardImplementation();
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~UDPStandardImplementation();
|
||||
|
||||
|
||||
|
||||
//*** Overloaded Functions called by TCP Interface ***
|
||||
|
||||
/**
|
||||
* Get Total Frames Caught for an entire acquisition (including all scans)
|
||||
* @return total number of frames caught for entire acquisition
|
||||
*/
|
||||
uint64_t getTotalFramesCaught() const;
|
||||
|
||||
/**
|
||||
* Get Frames Caught for each real time acquisition (eg. for each scan)
|
||||
* @return number of frames caught for each scan
|
||||
*/
|
||||
uint64_t getFramesCaught() const;
|
||||
|
||||
/**
|
||||
* Get Current Frame Index for an entire acquisition (including all scans)
|
||||
* @return -1 if no frames have been caught, else current frame index (represents all scans too)
|
||||
*/
|
||||
int64_t getAcquisitionIndex() const;
|
||||
|
||||
/**
|
||||
* Set Gap Pixels Enable (eiger specific)
|
||||
* @param b true for gap pixels enable, else false
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int setGapPixelsEnable(const bool b);
|
||||
|
||||
/**
|
||||
* Set File Format
|
||||
* @param f fileformat binary or hdf5
|
||||
*/
|
||||
void setFileFormat(slsReceiverDefs::fileFormat f);
|
||||
|
||||
/**
|
||||
* Set File Write Enable
|
||||
* @param b true for file write enable, else false
|
||||
*/
|
||||
void setFileWriteEnable(const bool b);
|
||||
|
||||
/**
|
||||
* Set ROI
|
||||
* @param i ROI
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int setROI(const std::vector<ROI> i);
|
||||
|
||||
/**
|
||||
* Set the Frequency of Frames Sent to GUI
|
||||
* @param freq 0 for random frame requests, n for nth frame frequency
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int setFrameToGuiFrequency(const uint32_t freq);
|
||||
|
||||
/**
|
||||
* Set the data stream enable
|
||||
* @param enable data stream enable
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int setDataStreamEnable(const bool enable);
|
||||
|
||||
/**
|
||||
* Set Number of Samples expected by receiver from detector
|
||||
* @param i number of Samples expected
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int setNumberofSamples(const uint64_t i);
|
||||
|
||||
/**
|
||||
* Set Dynamic Range or Number of Bits Per Pixel
|
||||
* @param i dynamic range that is 4, 8, 16 or 32
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int setDynamicRange(const uint32_t i);
|
||||
|
||||
/**
|
||||
* Set Ten Giga Enable
|
||||
* @param b true if 10GbE enabled, else false (1G enabled)
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int setTenGigaEnable(const bool b);
|
||||
|
||||
/**
|
||||
* Set Fifo Depth
|
||||
* @param i fifo depth value
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int setFifoDepth(const uint32_t i);
|
||||
|
||||
|
||||
/**
|
||||
* Set receiver type (and corresponding detector variables in derived STANDARD class)
|
||||
* It is the first function called by the client when connecting to receiver
|
||||
* @param d detector type
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int setDetectorType(const detectorType d);
|
||||
|
||||
/**
|
||||
* Set detector position id and construct filewriter
|
||||
* @param i position id
|
||||
*/
|
||||
void setDetectorPositionId(const int i);
|
||||
|
||||
/**
|
||||
* Reset acquisition parameters such as total frames caught for an entire acquisition (including all scans)
|
||||
*/
|
||||
void resetAcquisitionCount();
|
||||
|
||||
/**
|
||||
* Start Listening for Packets by activating all configuration settings to receiver
|
||||
* When this function returns, it has status RUNNING(upon SUCCESS) or IDLE (upon failure)
|
||||
* @param c error message if FAIL
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int startReceiver(char *c=NULL);
|
||||
|
||||
/**
|
||||
* Stop Listening for Packets
|
||||
* Calls startReadout(), which stops listening and sets status to Transmitting
|
||||
* When it has read every frame in buffer, the status changes to Run_Finished
|
||||
* When this function returns, receiver has status IDLE
|
||||
* Pre: status is running, semaphores have been instantiated,
|
||||
* Post: udp sockets shut down, status is idle, semaphores destroyed
|
||||
*/
|
||||
void stopReceiver();
|
||||
|
||||
/**
|
||||
* Stop Listening to Packets
|
||||
* and sets status to Transmitting
|
||||
* Next step would be to get all data and stop receiver completely and return with idle state
|
||||
* Pre: status is running, udp sockets have been initialized, stop receiver initiated
|
||||
* Post:udp sockets closed, status is transmitting
|
||||
*/
|
||||
void startReadout();
|
||||
|
||||
/**
|
||||
* Shuts down and deletes UDP Sockets
|
||||
* also called in case of illegal shutdown of receiver
|
||||
*/
|
||||
void shutDownUDPSockets();
|
||||
|
||||
/**
|
||||
* Closes file / all files(data compression involves multiple files)
|
||||
*/
|
||||
void closeFiles();
|
||||
|
||||
/** (not saved in client shared memory)
|
||||
* Set UDP Socket Buffer Size
|
||||
* @param s UDP Socket Buffer Size
|
||||
* @return OK or FAIL if dummy socket could be created
|
||||
*/
|
||||
int setUDPSocketBufferSize(const uint32_t s);
|
||||
|
||||
/**
|
||||
* Restream stop dummy packet from receiver
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int restreamStop();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Delete and free member parameters
|
||||
*/
|
||||
void DeleteMembers();
|
||||
|
||||
/**
|
||||
* Initialize member parameters
|
||||
*/
|
||||
void InitializeMembers();
|
||||
|
||||
/**
|
||||
* Sets local network parameters, but requires permissions
|
||||
*/
|
||||
void SetLocalNetworkParameters();
|
||||
|
||||
/**
|
||||
* Set Thread Priorities
|
||||
*/
|
||||
void SetThreadPriorities();
|
||||
|
||||
/**
|
||||
* Set up the Fifo Structure for processing buffers
|
||||
* between listening and dataprocessor threads
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int SetupFifoStructure();
|
||||
|
||||
/**
|
||||
* Reset parameters for new measurement (eg. for each scan)
|
||||
*/
|
||||
void ResetParametersforNewMeasurement();
|
||||
|
||||
/**
|
||||
* Creates UDP Sockets
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int CreateUDPSockets();
|
||||
|
||||
/**
|
||||
* Creates the first file
|
||||
* also does the startAcquisitionCallBack
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int SetupWriter();
|
||||
|
||||
/**
|
||||
* Start Running
|
||||
* Set running mask and post semaphore of the threads
|
||||
* to start the inner loop in execution thread
|
||||
*/
|
||||
void StartRunning();
|
||||
|
||||
|
||||
|
||||
//*** Class Members ***
|
||||
|
||||
|
||||
//*** receiver parameters ***
|
||||
/** Number of Threads */
|
||||
int numThreads;
|
||||
|
||||
/** Number of Jobs */
|
||||
int numberofJobs;
|
||||
|
||||
/** Number of channels in roi for jungfrauctb */
|
||||
uint32_t nroichannels;
|
||||
|
||||
//** class objects ***
|
||||
/** General Data Properties */
|
||||
GeneralData* generalData;
|
||||
|
||||
/** Listener Objects that listen to UDP and push into fifo */
|
||||
std::vector <Listener*> listener;
|
||||
|
||||
/** DataProcessor Objects that pull from fifo and process data */
|
||||
std::vector <DataProcessor*> dataProcessor;
|
||||
|
||||
/** DataStreamer Objects that stream data via ZMQ */
|
||||
std::vector <DataStreamer*> dataStreamer;
|
||||
|
||||
/** Fifo Structure to store addresses of memory writes */
|
||||
std::vector <Fifo*> fifo;
|
||||
|
||||
};
|
||||
|
@ -6,12 +6,9 @@
|
||||
|
||||
|
||||
|
||||
#include "slsReceiverTCPIPInterface.h"
|
||||
#include "UDPInterface.h"
|
||||
class slsReceiverTCPIPInterface;
|
||||
|
||||
#include "receiver_defs.h"
|
||||
#include "MySocketTCP.h"
|
||||
//#include "utilities.h"
|
||||
#include "sls_receiver_defs.h"
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1,39 +1,39 @@
|
||||
#pragma once
|
||||
/********************************************//**
|
||||
* @file UDPBaseImplementation.h
|
||||
* @file slsReceiverImplementation.h
|
||||
* @short does all the functions for a receiver, set/get parameters, start/stop etc.
|
||||
***********************************************/
|
||||
|
||||
//#include "sls_receiver_defs.h"
|
||||
#include "UDPInterface.h"
|
||||
//#include <stdio.h>
|
||||
|
||||
/**
|
||||
* @short does all the base 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_receiver_defs.h"
|
||||
#include "receiver_defs.h"
|
||||
#include "logger.h"
|
||||
|
||||
class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInterface {
|
||||
|
||||
class GeneralData;
|
||||
class Listener;
|
||||
class DataProcessor;
|
||||
class DataStreamer;
|
||||
class Fifo;
|
||||
|
||||
#include <exception>
|
||||
#include <vector>
|
||||
|
||||
class slsReceiverImplementation: private virtual slsReceiverDefs {
|
||||
public:
|
||||
|
||||
/*************************************************************************
|
||||
* Constructor & Destructor **********************************************
|
||||
* They access local cache of configuration or detector parameters *******
|
||||
*************************************************************************/
|
||||
|
||||
//*** cosntructor & destructor ***
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
UDPBaseImplementation();
|
||||
slsReceiverImplementation();
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~UDPBaseImplementation();
|
||||
virtual ~slsReceiverImplementation();
|
||||
|
||||
/*
|
||||
* Initialize class members
|
||||
*/
|
||||
void initializeMembers();
|
||||
|
||||
/*************************************************************************
|
||||
* Getters ***************************************************************
|
||||
@ -47,7 +47,6 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
*/
|
||||
int* getMultiDetectorSize() const;
|
||||
|
||||
|
||||
/*
|
||||
* Get detector position id
|
||||
* @return detector position id
|
||||
@ -115,12 +114,6 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
*/
|
||||
bool getFramePaddingEnable() const;
|
||||
|
||||
/**
|
||||
* Get Scan Tag
|
||||
* @return scan tag //FIXME: needed? (unsigned integer?)
|
||||
*/
|
||||
int getScanTag() const;
|
||||
|
||||
/**
|
||||
* Get File Write Enable
|
||||
* @return true if file write enabled, else false
|
||||
@ -133,12 +126,6 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
*/
|
||||
bool getOverwriteEnable() const;
|
||||
|
||||
/**
|
||||
* Get data compression, by saving only hits (so far implemented only for Moench and Gotthard)
|
||||
* @return true if data compression enabled, else false
|
||||
*/
|
||||
bool getDataCompressionEnable() const;
|
||||
|
||||
|
||||
//***acquisition count parameters***
|
||||
/**
|
||||
@ -188,16 +175,16 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
std::vector<ROI> getROI() const;
|
||||
|
||||
/**
|
||||
* Get the Frequency of Frames Sent to GUI
|
||||
* @return 0 for random frame requests, n for nth frame frequency
|
||||
* Get the streaming frequency
|
||||
* @return 0 for timer, n for nth frame frequency
|
||||
*/
|
||||
uint32_t getFrameToGuiFrequency() const;
|
||||
uint32_t getStreamingFrequency() const;
|
||||
|
||||
/**
|
||||
* Gets the timer between frames streamed when frequency is set to 0
|
||||
* @return timer between frames streamed
|
||||
*/
|
||||
uint32_t getFrameToGuiTimer() const;
|
||||
uint32_t getStreamingTimer() const;
|
||||
|
||||
/**
|
||||
* Get the data stream enable
|
||||
@ -329,10 +316,10 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
|
||||
//**initial parameters***
|
||||
/**
|
||||
* Configure command line parameters
|
||||
* @param config_map mapping of config parameters passed from command line arguments
|
||||
* Sets detector hostname
|
||||
* @param c detector hostname
|
||||
*/
|
||||
void configure(std::map<std::string, std::string> config_map);
|
||||
void setDetectorHostname(const char *c);
|
||||
|
||||
/*
|
||||
* Set multi detector size
|
||||
@ -400,12 +387,6 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
*/
|
||||
void setFramePaddingEnable(const bool i);
|
||||
|
||||
/**
|
||||
* Set Scan Tag
|
||||
* @param i scan tag //FIXME: needed? (unsigned integer?)
|
||||
*/
|
||||
void setScanTag(const int i);
|
||||
|
||||
/**
|
||||
* Set File Write Enable
|
||||
* @param b true for file write enable, else false
|
||||
@ -418,14 +399,6 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
*/
|
||||
void setOverwriteEnable(const bool b);
|
||||
|
||||
/**
|
||||
* Set data compression, by saving only hits (so far implemented only for Moench and Gotthard)
|
||||
* @param b true for data compression enable, else false
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int setDataCompressionEnable(const bool b);
|
||||
|
||||
|
||||
//***connection parameters***
|
||||
/**
|
||||
* Set UDP Port Number
|
||||
@ -445,6 +418,13 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
*/
|
||||
void setEthernetInterface(const char* c);
|
||||
|
||||
/** (not saved in client shared memory)
|
||||
* Set UDP Socket Buffer Size
|
||||
* @param s UDP Socket Buffer Size
|
||||
* @return OK or FAIL if dummy socket could be created
|
||||
*/
|
||||
int setUDPSocketBufferSize(const uint32_t s);
|
||||
|
||||
|
||||
//***acquisition parameters***
|
||||
/**
|
||||
@ -455,18 +435,17 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
int setROI(const std::vector<ROI> i);
|
||||
|
||||
/**
|
||||
* Set the Frequency of Frames Sent to GUI
|
||||
* @param freq 0 for random frame requests, n for nth frame frequency
|
||||
* Set the streaming frequency
|
||||
* @param freq 0 for timer, n for nth frame frequency
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int setFrameToGuiFrequency(const uint32_t freq);
|
||||
int setStreamingFrequency(const uint32_t freq);
|
||||
|
||||
/**
|
||||
* Sets the timer between frames streamed when frequency is set to 0
|
||||
* @param time_in_ms timer between frames streamed
|
||||
*/
|
||||
void setFrameToGuiTimer(const uint32_t time_in_ms);
|
||||
|
||||
void setStreamingTimer(const uint32_t time_in_ms);
|
||||
/**
|
||||
* Set the data stream enable
|
||||
* @param enable data stream enable
|
||||
@ -474,6 +453,23 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
*/
|
||||
int setDataStreamEnable(const bool enable);
|
||||
|
||||
/**
|
||||
* Set streaming port
|
||||
* @param i streaming port
|
||||
*/
|
||||
void setStreamingPort(const uint32_t i);
|
||||
|
||||
/**
|
||||
* Set streaming source ip
|
||||
* @param c streaming source ip
|
||||
*/
|
||||
void setStreamingSourceIP(const char* c);
|
||||
|
||||
/**
|
||||
* Set additional json header
|
||||
*/
|
||||
void setAdditionalJsonHeader(const char* c);
|
||||
|
||||
/**
|
||||
* Set Acquisition Period
|
||||
* @param i acquisition period
|
||||
@ -525,7 +521,7 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
|
||||
/**
|
||||
* Set Ten Giga Enable
|
||||
* @param b true if 10Giga enabled, else false (1G enabled)
|
||||
* @param b true if 10GbE enabled, else false (1G enabled)
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int setTenGigaEnable(const bool b);
|
||||
@ -537,80 +533,8 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
*/
|
||||
int setFifoDepth(const uint32_t i);
|
||||
|
||||
|
||||
//***receiver parameters***
|
||||
/**
|
||||
* Set Silent Mode
|
||||
* @param i silent mode. true sets, false unsets
|
||||
*/
|
||||
void setSilentMode(const bool i);
|
||||
|
||||
/*************************************************************************
|
||||
* Behavioral functions***************************************************
|
||||
* They may modify the status of the receiver ****************************
|
||||
*************************************************************************/
|
||||
|
||||
|
||||
//***initial functions***
|
||||
/**
|
||||
* Set receiver type (and corresponding detector variables in derived STANDARD class)
|
||||
* It is the first function called by the client when connecting to receiver
|
||||
* @param d detector type
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int setDetectorType(const detectorType d);
|
||||
|
||||
/**
|
||||
* Set detector position id
|
||||
* @param i position id
|
||||
*/
|
||||
void setDetectorPositionId(const int i);
|
||||
|
||||
/**
|
||||
* Sets detector hostname
|
||||
* It is second function called by the client when connecting to receiver.
|
||||
* you can call this function only once.
|
||||
* @param c detector hostname
|
||||
*/
|
||||
void initialize(const char *c);
|
||||
|
||||
|
||||
//***acquisition functions***
|
||||
/**
|
||||
* Reset acquisition parameters such as total frames caught for an entire acquisition (including all scans)
|
||||
*/
|
||||
void resetAcquisitionCount();
|
||||
|
||||
/**
|
||||
* Start Listening for Packets by activating all configuration settings to receiver
|
||||
* @param c error message if FAIL
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int startReceiver(char *c=NULL);
|
||||
|
||||
/**
|
||||
* Stop Listening for Packets
|
||||
* Calls startReadout(), which stops listening and sets status to Transmitting
|
||||
* When it has read every frame in buffer,it returns with the status Run_Finished
|
||||
*/
|
||||
void stopReceiver();
|
||||
|
||||
/**
|
||||
* Stop Listening to Packets
|
||||
* and sets status to Transmitting
|
||||
*/
|
||||
void startReadout();
|
||||
|
||||
/**
|
||||
* Shuts down and deletes UDP Sockets
|
||||
*/
|
||||
void shutDownUDPSockets();
|
||||
|
||||
/**
|
||||
* abort acquisition with minimum damage: close open files, cleanup.
|
||||
* does nothing if state already is 'idle'
|
||||
*/
|
||||
void abort(); //FIXME: needed, isn't stopReceiver enough?
|
||||
|
||||
/**
|
||||
* Activate / Deactivate Receiver
|
||||
* If deactivated, receiver will create dummy data if deactivated padding is enabled
|
||||
@ -630,30 +554,77 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
bool setDeactivatedPadding(const bool enable);
|
||||
|
||||
/**
|
||||
* Set streaming port
|
||||
* @param i streaming port
|
||||
* Set Silent Mode
|
||||
* @param i silent mode. true sets, false unsets
|
||||
*/
|
||||
void setStreamingPort(const uint32_t i);
|
||||
void setSilentMode(const bool i);
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Behavioral functions***************************************************
|
||||
* They may modify the status of the receiver ****************************
|
||||
*************************************************************************/
|
||||
|
||||
//***initial functions***
|
||||
/**
|
||||
* Set receiver type (and corresponding detector variables in derived STANDARD class)
|
||||
* It is the first function called by the client when connecting to receiver
|
||||
* @param d detector type
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int setDetectorType(const detectorType d);
|
||||
|
||||
/**
|
||||
* Set streaming source ip
|
||||
* @param c streaming source ip
|
||||
* Set detector position id and construct filewriter
|
||||
* @param i position id
|
||||
*/
|
||||
void setStreamingSourceIP(const char* c);
|
||||
void setDetectorPositionId(const int i);
|
||||
|
||||
/**
|
||||
* Set additional json header
|
||||
*/
|
||||
void setAdditionalJsonHeader(const char* c);
|
||||
//***acquisition functions***
|
||||
/**
|
||||
* Reset acquisition parameters such as total frames caught for an entire acquisition (including all scans)
|
||||
*/
|
||||
void resetAcquisitionCount();
|
||||
|
||||
/** (not saved in client shared memory)
|
||||
* Set UDP Socket Buffer Size
|
||||
* @param s UDP Socket Buffer Size
|
||||
* @return OK or FAIL if dummy socket could be created
|
||||
*/
|
||||
int setUDPSocketBufferSize(const uint32_t s);
|
||||
/**
|
||||
* Start Listening for Packets by activating all configuration settings to receiver
|
||||
* When this function returns, it has status RUNNING(upon SUCCESS) or IDLE (upon failure)
|
||||
* @param c error message if FAIL
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int startReceiver(char *c=NULL);
|
||||
|
||||
/*
|
||||
/**
|
||||
* Stop Listening for Packets
|
||||
* Calls startReadout(), which stops listening and sets status to Transmitting
|
||||
* When it has read every frame in buffer, the status changes to Run_Finished
|
||||
* When this function returns, receiver has status IDLE
|
||||
* Pre: status is running, semaphores have been instantiated,
|
||||
* Post: udp sockets shut down, status is idle, semaphores destroyed
|
||||
*/
|
||||
void stopReceiver();
|
||||
|
||||
/**
|
||||
* Stop Listening to Packets
|
||||
* and sets status to Transmitting
|
||||
* Next step would be to get all data and stop receiver completely and return with idle state
|
||||
* Pre: status is running, udp sockets have been initialized, stop receiver initiated
|
||||
* Post:udp sockets closed, status is transmitting
|
||||
*/
|
||||
void startReadout();
|
||||
|
||||
/**
|
||||
* Shuts down and deletes UDP Sockets
|
||||
* also called in case of illegal shutdown of receiver
|
||||
*/
|
||||
void shutDownUDPSockets();
|
||||
|
||||
/**
|
||||
* Closes file / all files(data compression involves multiple files)
|
||||
*/
|
||||
void closeFiles();
|
||||
|
||||
/**
|
||||
* Restream stop dummy packet from receiver
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
@ -702,8 +673,61 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
void registerCallBackRawDataModifyReady(void (*func)(char* ,
|
||||
char*, uint32_t &,void*),void *arg);
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Delete and free member parameters
|
||||
*/
|
||||
void DeleteMembers();
|
||||
|
||||
/**
|
||||
* Initialize member parameters
|
||||
*/
|
||||
void InitializeMembers();
|
||||
|
||||
/**
|
||||
* Sets local network parameters, but requires permissions
|
||||
*/
|
||||
void SetLocalNetworkParameters();
|
||||
|
||||
/**
|
||||
* Set Thread Priorities
|
||||
*/
|
||||
void SetThreadPriorities();
|
||||
|
||||
/**
|
||||
* Set up the Fifo Structure for processing buffers
|
||||
* between listening and dataprocessor threads
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int SetupFifoStructure();
|
||||
|
||||
/**
|
||||
* Reset parameters for new measurement (eg. for each scan)
|
||||
*/
|
||||
void ResetParametersforNewMeasurement();
|
||||
|
||||
/**
|
||||
* Creates UDP Sockets
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int CreateUDPSockets();
|
||||
|
||||
/**
|
||||
* Creates the first file
|
||||
* also does the startAcquisitionCallBack
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int SetupWriter();
|
||||
|
||||
/**
|
||||
* Start Running
|
||||
* Set running mask and post semaphore of the threads
|
||||
* to start the inner loop in execution thread
|
||||
*/
|
||||
void StartRunning();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/*************************************************************************
|
||||
* Class Members *********************************************************
|
||||
@ -740,7 +764,13 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
/** gap pixels enable */
|
||||
bool gapPixelsEnable;
|
||||
|
||||
//***receiver parameters***
|
||||
//*** receiver parameters ***
|
||||
/** Number of Threads */
|
||||
int numThreads;
|
||||
/** Number of Jobs */
|
||||
int numberofJobs;
|
||||
/** Number of channels in roi for jungfrauctb */
|
||||
uint32_t nroichannels;
|
||||
/** Maximum Number of Listening Threads/ UDP Ports */
|
||||
const static int MAX_NUMBER_OF_LISTENING_THREADS = 2;
|
||||
/** Receiver Status */
|
||||
@ -753,6 +783,8 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
frameDiscardPolicy frameDiscardMode;
|
||||
/** frame padding */
|
||||
bool framePadding;
|
||||
/** silent mode */
|
||||
bool silentMode;
|
||||
|
||||
//***connection parameters***
|
||||
/** Ethernet Interface */
|
||||
@ -764,7 +796,7 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
/** actual UDP Socket Buffer Size (halved due to kernel bookkeeping) */
|
||||
uint32_t actualUDPSocketBufferSize;
|
||||
|
||||
//***file parameters***
|
||||
//***file parameters***
|
||||
/** File format */
|
||||
fileFormat fileFormatType;
|
||||
/** File Name without frame index, file index and extension (_d0_f000000000000_8.raw)*/
|
||||
@ -775,22 +807,18 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
uint64_t fileIndex;
|
||||
/** Frames per file (0 means infinite) */
|
||||
uint32_t framesPerFile;
|
||||
/** Scan Tag */
|
||||
int scanTag;
|
||||
/** File Write enable */
|
||||
bool fileWriteEnable;
|
||||
/** Overwrite enable */
|
||||
bool overwriteEnable;
|
||||
/** Data Compression Enable - save only hits */
|
||||
bool dataCompressionEnable;
|
||||
|
||||
//***acquisition parameters***
|
||||
/* ROI */
|
||||
std::vector<ROI> roi;
|
||||
/** Frequency of Frames sent to GUI */
|
||||
uint32_t frameToGuiFrequency;
|
||||
/** Timer of Frames sent to GUI when frequency is 0 */
|
||||
uint32_t frameToGuiTimerinMS;
|
||||
/** streaming frequency */
|
||||
uint32_t streamingFrequency;
|
||||
/** Streaming timer when frequency is 0 */
|
||||
uint32_t streamingTimerInMs;
|
||||
/** Data Stream Enable from Receiver */
|
||||
bool dataStreamEnable;
|
||||
/** streaming port */
|
||||
@ -800,10 +828,17 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
/** additional json header */
|
||||
char additionalJsonHeader[MAX_STR_LENGTH];
|
||||
|
||||
//***receiver parameters***
|
||||
bool silentMode;
|
||||
|
||||
|
||||
//** class objects ***
|
||||
/** General Data Properties */
|
||||
GeneralData* generalData;
|
||||
/** Listener Objects that listen to UDP and push into fifo */
|
||||
std::vector <Listener*> listener;
|
||||
/** DataProcessor Objects that pull from fifo and process data */
|
||||
std::vector <DataProcessor*> dataProcessor;
|
||||
/** DataStreamer Objects that stream data via ZMQ */
|
||||
std::vector <DataStreamer*> dataStreamer;
|
||||
/** Fifo Structure to store addresses of memory writes */
|
||||
std::vector <Fifo*> fifo;
|
||||
|
||||
//***callback parameters***
|
||||
/**
|
||||
@ -820,7 +855,6 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
*/
|
||||
int (*startAcquisitionCallBack)(char*, char*, uint64_t, uint32_t, void*);
|
||||
void *pStartAcquisition;
|
||||
|
||||
/**
|
||||
* Call back for acquisition finished
|
||||
* callback argument is
|
||||
@ -828,8 +862,6 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
*/
|
||||
void (*acquisitionFinishedCallBack)(uint64_t, void*);
|
||||
void *pAcquisitionFinished;
|
||||
|
||||
|
||||
/**
|
||||
* Call back for raw data
|
||||
* args to raw data ready callback are
|
||||
@ -839,7 +871,6 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
*/
|
||||
void (*rawDataReadyCallBack)(char* ,
|
||||
char*, uint32_t, void*);
|
||||
|
||||
/**
|
||||
* Call back for raw data (modified)
|
||||
* args to raw data ready callback are
|
||||
@ -849,11 +880,8 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
*/
|
||||
void (*rawDataModifyReadyCallBack)(char* ,
|
||||
char*, uint32_t &, void*);
|
||||
|
||||
void *pRawDataReady;
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
@ -7,8 +7,9 @@
|
||||
|
||||
#include "sls_receiver_defs.h"
|
||||
#include "receiver_defs.h"
|
||||
#include "MySocketTCP.h"
|
||||
#include "UDPInterface.h"
|
||||
|
||||
class MySocketTCP;
|
||||
class slsReceiverImplementation;
|
||||
|
||||
|
||||
|
||||
@ -175,8 +176,8 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs {
|
||||
/** set dynamic range */
|
||||
int set_dynamic_range();
|
||||
|
||||
/** Sets the receiver to send every nth frame to gui, or only upon gui request */
|
||||
int set_read_frequency();
|
||||
/** Sets the receiver streaming frequency */
|
||||
int set_streaming_frequency();
|
||||
|
||||
/** Gets receiver status */
|
||||
int get_status();
|
||||
@ -187,10 +188,6 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs {
|
||||
/** Stop Receiver - stops listening to udp packets from detector*/
|
||||
int stop_receiver();
|
||||
|
||||
/** set status to transmitting and
|
||||
* when fifo is empty later, sets status to run_finished */
|
||||
int start_readout();
|
||||
|
||||
/** Set File path */
|
||||
int set_file_dir();
|
||||
|
||||
@ -230,8 +227,8 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs {
|
||||
/* Set the data stream enable */
|
||||
int set_data_stream_enable();
|
||||
|
||||
/** Sets the timer between frames streamed by receiver when frequency is set to 0 */
|
||||
int set_read_receiver_timer();
|
||||
/** Sets the steadming timer when frequency is set to 0 */
|
||||
int set_streaming_timer();
|
||||
|
||||
/** enable flipped data */
|
||||
int set_flipped_data();
|
||||
@ -289,7 +286,7 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs {
|
||||
detectorType myDetectorType;
|
||||
|
||||
/** slsReceiverBase object */
|
||||
UDPInterface *receiverBase;
|
||||
slsReceiverImplementation *receiverBase;
|
||||
|
||||
/** Function List */
|
||||
int (slsReceiverTCPIPInterface::*flist[NUM_REC_FUNCTIONS])();
|
||||
|
Reference in New Issue
Block a user