Transient Recorder Framework
Public Member Functions | List of all members
TRChannelDataSubmit Class Reference

Class for submitting burst data. More...

#include <TRChannelDataSubmit.h>

Inheritance diagram for TRChannelDataSubmit:

Public Member Functions

 TRChannelDataSubmit ()
 Constructor for the data-submit object. More...
 
 ~TRChannelDataSubmit ()
 Destructor for the data-submit object. More...
 
bool allocateArray (TRBaseDriver &driver, int channel_num, NDDataType_t data_type, int num_samples)
 Set parameters for the array and allocate the NDArray. More...
 
void releaseArray ()
 Release any array. More...
 
void * data ()
 Returns the data pointer of the array. More...
 
void submit (TRBaseDriver &driver, int channel, int unique_id, double timestamp, epicsTimeStamp epics_ts, TRArrayCompletionCallback *compl_cb)
 Submit the array to AreaDetector. More...
 

Detailed Description

Class for submitting burst data.

This object does not have any protection from concurrent use. It is intended to be used within a function on the same thread. Multi-threaded use is possible but external locking is needed in that case.

Constructor & Destructor Documentation

TRChannelDataSubmit::TRChannelDataSubmit ( )
inline

Constructor for the data-submit object.

The constructor does not have any parameters and allocateArray should be used to allocate the array with the right settings. This allows making an array of these objects.

This class has two major states: without-array (default) and with-array (after a successful allocateArray).

TRChannelDataSubmit::~TRChannelDataSubmit ( )
inline

Destructor for the data-submit object.

It ensures that any array is released at destruction.

Member Function Documentation

bool TRChannelDataSubmit::allocateArray ( TRBaseDriver driver,
int  channel_num,
NDDataType_t  data_type,
int  num_samples 
)

Set parameters for the array and allocate the NDArray.

This may only be called in the without-array state. Upon success, the state changes to with-array.

This function MUST be called with the base and channels drivers unlocked.

Parameters
driverThe TRBaseDriver to which the data would be submitted.
channel_numChannel number for data. Must be a valid channel number for the TRBaseDriver.
data_typeThe AreaDetector data type for the array.
num_samplesNumber of samples for the burst.
Returns
true on success, false on error
void TRChannelDataSubmit::releaseArray ( )
inline

Release any array.

After this the state is witout-array.

void* TRChannelDataSubmit::data ( )
inline

Returns the data pointer of the array.

This will return NULL if the state is without-array. It is important that the caller checks for NULL before writing data. To write the data, this pointer should be cast to the pointer to type corresponding to the data type of the array as allocated.

This function is not maximally efficient. Avoid calling this in a tight loop and cache the pointer instead.

Returns
The data pointer of the NDArray, or NULL if there is no array.
void TRChannelDataSubmit::submit ( TRBaseDriver driver,
int  channel,
int  unique_id,
double  timestamp,
epicsTimeStamp  epics_ts,
TRArrayCompletionCallback compl_cb 
)

Submit the array to AreaDetector.

It is acceptable to call this in the without-array state, notably after a failed allocateArray. After this, the state is without-array (submitting an array implies relasing it).

If called in the with-array state, the driver and channel arguments must be the same as was used in the allocateArray call when the array was allocated.

This function will discard the data if disarming has already been initiated.

This function MUST be called with the base and channels drivers unlocked.

Parameters
driverThe TRBaseDriver as was passed to allocateArray.
channelThe channel number as was passed to allocateArray.
unique_idThe unique_id for the NDArray.
timestampThe timestamp for the NDArray.
epics_tsThe epicsTimeStamp for the NDArray.
compl_cbOptional callback to be called just before submitting the NDArray, after meta-information including timestamps and attributes have been set. This allows overriding any information in the array and adding additional attributes. It is called with the channels port (TRChannelsDriver) locked. This callbacks also allows inhibiting array submission.

The documentation for this class was generated from the following file: