MIRA
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
TapeRecorder Class Reference

Class for recording channel data to tape. More...

#include <fw/TapeRecorder.h>

Classes

class  ChannelInfo
 Informations about a recorded channel. More...
 

Public Types

typedef std::map< std::string,
ChannelInfo
ChannelMap
 Typedef for ChannelInfo pointers. More...
 

Public Member Functions

 TapeRecorder (const Duration &initialWaitForDataDuration=Duration::seconds(0))
 Create a TapeRecorder. More...
 
virtual ~TapeRecorder ()
 
template<typename Reflector >
void reflect (Reflector &r)
 
 MIRA_DEPRECATED ("Please use int compressionLevel(=0/-1) instead of bool compress(=false/true)", void addChannel(const std::string &channelID, const std::list< BinarySerializerCodecPtr > &codecs, bool compress, Duration interval=Duration::microseconds(0), bool avoidDataLoss=false))
 Add a channel to the list of recorded channels. More...
 
void addChannel (const std::string &channelID, const std::list< BinarySerializerCodecPtr > &codecs=std::list< BinarySerializerCodecPtr >(), int compressionLevel=0, Duration interval=Duration::microseconds(0), bool avoidDataLoss=false)
 Add a channel to the list of recorded channels. More...
 
void addChannel (const std::string &channelID, const RecordedChannelInfo &info)
 Add a channel to the list of recorded channels by providing an ID and an info object that contains the settings for the channel. More...
 
void record (const Path &file)
 Start recording to file. More...
 
void record (const TapeRecorderConfig &config)
 Start recording to file using a recorder config that contains channels and settings for recording. More...
 
void stop (bool finishQueue=true)
 Stop recording. More...
 
size_t storageQueueSize ()
 Query size of internal storage queue. More...
 
void processStorageQueue (int numEntries=1)
 Process single element or a specified number of elements from storage queue. More...
 
void setMaxMessageBlockSize (uint32 maxMessageBlockSize)
 Set the maximum size of the chunks. More...
 
bool isRecording () const
 Returns whether TapeRecorder is currently gathering data after record was called. More...
 
const PerformanceStatisticsgetStats (const std::string &name)
 

Protected Member Functions

void valueChanged (ChannelRead< void > value, bool forceStorage=false)
 
void intervalValueChanged (ChannelReadInterval< void > values, bool forceStorage=false)
 

Protected Attributes

Authority mAuthority
 
uint32 mMaxMessageBlockSize
 
Tape mTape
 
bool mIsRecording
 
bool mFirstCallbackMessage
 
ChannelMap mChannels
 
Duration mInitialWaitForDataDuration
 
boost::thread mStorageThread
 
boost::condition_variable mStorageThreadCondition
 
boost::mutex mStorageMutex
 
bool mStorageThreadStarted
 
std::deque< MessageToStore > mStorageQueue
 
volatile bool mStorageThreadTerminationRequest
 

Detailed Description

Class for recording channel data to tape.

Member Typedef Documentation

typedef std::map<std::string, ChannelInfo> ChannelMap

Typedef for ChannelInfo pointers.

Constructor & Destructor Documentation

TapeRecorder ( const Duration initialWaitForDataDuration = Duration::seconds(0))

Create a TapeRecorder.

Parameters
[in]initialWaitForDataDurationMax time to wait for initial data in all recorded channels. The purpose is to give channels published remotely some time after subscribing to receive data already published in the past. The given duration is the max total waiting time for all recorded channels (i.e. determination of the tape start time begins after 1 data update is read from each recorded channel, or when the time has passed after calling record(), whichever happens first).
virtual ~TapeRecorder ( )
virtual

Member Function Documentation

void reflect ( Reflector &  r)
inline
MIRA_DEPRECATED ( "Please use int compressionLevel(=0/-1) instead of bool compress(=false/true)"  ,
void   addChannelconst std::string &channelID,const std::list< BinarySerializerCodecPtr > &codecs,bool compress, Duration interval=Duration::microseconds(0), bool avoidDataLoss=false 
)
inline

Add a channel to the list of recorded channels.

Parameters
[in]channelIDName of the channel
[in]codecsA list of used codecs or empty if none
[in]compressShould the channel data be recorded in a compressed format (zip)
[in]intervalInterval in which the data gets recorded. E.g. if a channel changes every 10 ms and the interval is 100 ms, only 1 out of 10 changes are recorded.
[in]avoidDataLossAvoid data loss on the channel during recording by using subscribeInterval() instead of subscribe()
void addChannel ( const std::string &  channelID,
const std::list< BinarySerializerCodecPtr > &  codecs = std::list< BinarySerializerCodecPtr >(),
int  compressionLevel = 0,
Duration  interval = Duration::microseconds(0),
bool  avoidDataLoss = false 
)

Add a channel to the list of recorded channels.

Parameters
[in]channelIDName of the channel
[in]codecsA list of used codecs or empty if none
[in]compressionLevellibzip compression level for recorded channel data (0=none, 1..9=best speed to best compression, -1=default compression)
[in]intervalInterval in which the data gets recorded. E.g. if a channel changes every 10 ms and the interval is 100 ms, only 1 out of 10 changes are recorded.
[in]avoidDataLossAvoid data loss on the channel during recording by using subscribeInterval() instead of subscribe()
void addChannel ( const std::string &  channelID,
const RecordedChannelInfo info 
)

Add a channel to the list of recorded channels by providing an ID and an info object that contains the settings for the channel.

Parameters
[in]channelIDName of the channel
[in]infoSettings for recording the channel
void record ( const Path file)

Start recording to file.

Parameters
[in]fileFilename of the tape
void record ( const TapeRecorderConfig config)

Start recording to file using a recorder config that contains channels and settings for recording.

Parameters
[in]configA config containing all settings for recording
void stop ( bool  finishQueue = true)

Stop recording.

Parameters
[in]finishQueueIf true, the internal storage queue is finished before returning. Otherwise, items remain in the queue and the tape file is not finished, processStorageQueue() must be called until the queue is empty.
size_t storageQueueSize ( )

Query size of internal storage queue.

This can be called during recording or after stopping.

void processStorageQueue ( int  numEntries = 1)

Process single element or a specified number of elements from storage queue.

This should only be used to process remaining queue entries after recording was stopping with stop(finishQueue=false). This way, the external caller can control and monitor the number of elements to process (e.g. if it wants to display a progress bar).

Will throw XLogical if called while still recording.

void setMaxMessageBlockSize ( uint32  maxMessageBlockSize)
inline

Set the maximum size of the chunks.

Parameters
[in]maxMessageBlockSizeSize of a chunk in bytes
bool isRecording ( ) const
inline

Returns whether TapeRecorder is currently gathering data after record was called.

const PerformanceStatistics& getStats ( const std::string &  name)
void valueChanged ( ChannelRead< void >  value,
bool  forceStorage = false 
)
protected
void intervalValueChanged ( ChannelReadInterval< void >  values,
bool  forceStorage = false 
)
protected

Member Data Documentation

Authority mAuthority
protected
uint32 mMaxMessageBlockSize
protected
Tape mTape
protected
bool mIsRecording
protected
bool mFirstCallbackMessage
protected
ChannelMap mChannels
protected
Duration mInitialWaitForDataDuration
protected
boost::thread mStorageThread
protected
boost::condition_variable mStorageThreadCondition
protected
boost::mutex mStorageMutex
protected
bool mStorageThreadStarted
protected
std::deque<MessageToStore> mStorageQueue
protected
volatile bool mStorageThreadTerminationRequest
protected

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