MIRA
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, ChannelInfoChannelMap
 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...
 
void setWarnOfDataLoss (bool enable)
 Set whether detected data loss should show a warning. More...
 
bool getWarnOfDataLoss ()
 Query if data loss warning is enabled. 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

bool valueChanged (ChannelRead< void > value, bool forceStorage=false)
 
void intervalValueChanged (ChannelReadInterval< void > values, bool forceStorage=false)
 
void addAllTransformationChannels ()
 
Path timestampFilename (const Path &filenameBase)
 

Protected Attributes

Authority mAuthority
 
uint32 mMaxMessageBlockSize
 
bool mWarnDataLoss
 
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

◆ ChannelMap

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

Typedef for ChannelInfo pointers.

Constructor & Destructor Documentation

◆ TapeRecorder()

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).

◆ ~TapeRecorder()

virtual ~TapeRecorder ( )
virtual

Member Function Documentation

◆ reflect()

void reflect ( Reflector &  r)
inline

◆ MIRA_DEPRECATED()

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()

◆ addChannel() [1/2]

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()

◆ addChannel() [2/2]

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

◆ record() [1/2]

void record ( const Path file)

Start recording to file.

Parameters
[in]fileFilename of the tape

◆ record() [2/2]

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

◆ stop()

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.

◆ storageQueueSize()

size_t storageQueueSize ( )

Query size of internal storage queue.

This can be called during recording or after stopping.

◆ processStorageQueue()

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.

◆ setMaxMessageBlockSize()

void setMaxMessageBlockSize ( uint32  maxMessageBlockSize)
inline

Set the maximum size of the chunks.

Parameters
[in]maxMessageBlockSizeSize of a chunk in bytes

◆ setWarnOfDataLoss()

void setWarnOfDataLoss ( bool  enable)
inline

Set whether detected data loss should show a warning.

This only applies to channels which are configured to avoid data loss. it can only be detected if the channel data has valid sequence IDs.

Parameters
[in]enableWhether to enable the warning

◆ getWarnOfDataLoss()

bool getWarnOfDataLoss ( )
inline

Query if data loss warning is enabled.

◆ isRecording()

bool isRecording ( ) const
inline

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

◆ getStats()

const PerformanceStatistics& getStats ( const std::string &  name)

◆ valueChanged()

bool valueChanged ( ChannelRead< void >  value,
bool  forceStorage = false 
)
protected

◆ intervalValueChanged()

void intervalValueChanged ( ChannelReadInterval< void >  values,
bool  forceStorage = false 
)
protected

◆ addAllTransformationChannels()

void addAllTransformationChannels ( )
protected

◆ timestampFilename()

Path timestampFilename ( const Path filenameBase)
protected

Member Data Documentation

◆ mAuthority

Authority mAuthority
protected

◆ mMaxMessageBlockSize

uint32 mMaxMessageBlockSize
protected

◆ mWarnDataLoss

bool mWarnDataLoss
protected

◆ mTape

Tape mTape
protected

◆ mIsRecording

bool mIsRecording
protected

◆ mFirstCallbackMessage

bool mFirstCallbackMessage
protected

◆ mChannels

ChannelMap mChannels
protected

◆ mInitialWaitForDataDuration

Duration mInitialWaitForDataDuration
protected

◆ mStorageThread

boost::thread mStorageThread
protected

◆ mStorageThreadCondition

boost::condition_variable mStorageThreadCondition
protected

◆ mStorageMutex

boost::mutex mStorageMutex
protected

◆ mStorageThreadStarted

bool mStorageThreadStarted
protected

◆ mStorageQueue

std::deque<MessageToStore> mStorageQueue
protected

◆ mStorageThreadTerminationRequest

volatile bool mStorageThreadTerminationRequest
protected

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