SensAble_hduRecorder Class Reference

Collaboration diagram for SensAble_hduRecorder:

Collaboration graph
[legend]

List of all members.

Public Member Functions

HDboolean AddData ()
HDSchedulerHandle GetShedulerHandle ()
 SensAble_hduRecorder (FILE *file, HDURecordCallback &pUserCallback, void *pUserCallbackData, int numData)
HDboolean Start ()
void WriteDataToFile ()
virtual ~SensAble_hduRecorder ()

Private Attributes

SensAble_hduRecorderPacketm_data
FILE * m_file
HDSchedulerHandle m_hdSchedulerHandle
int m_index
int m_numData
SensAble_HDURecordCallback * m_pUserCallback
void * m_pUserCallbackData


Detailed Description

Definition at line 82 of file TAPsSensAble_hduRecord.cpp.


Constructor & Destructor Documentation

SensAble_hduRecorder::SensAble_hduRecorder ( FILE *  file,
HDURecordCallback &  pUserCallback,
void *  pUserCallbackData,
int  numData 
)

SensAble_hduRecorder::~SensAble_hduRecorder (  )  [virtual]

Definition at line 140 of file TAPsSensAble_hduRecord.cpp.

00141 {
00142     for ( int i = 0; i < m_numData; ++i ) {
00143         delete m_data[i].m_userData;
00144     }
00145     delete[] m_data;
00146 }


Member Function Documentation

HDboolean SensAble_hduRecorder::AddData (  ) 

Definition at line 247 of file TAPsSensAble_hduRecord.cpp.

00248 {
00249     //---------------------------------------------------------------
00250     // Get the data and fill one packet.
00251     static SensAble_hduRecorderPacket data;
00252     hdGetDoublev( HD_CURRENT_FORCE,     data.m_force );
00253     hdGetDoublev( HD_CURRENT_POSITION,  data.m_position );
00254     hdGetDoublev( HD_CURRENT_VELOCITY,  data.m_velocity );
00255     data.m_userData = 0;
00256     if ( m_pUserCallback ) {
00257         char * userData = ( * m_pUserCallback )( m_pUserCallbackData );
00258         data.m_userData = userData;
00259     }
00260     //---------------------------------------------------------------
00261     // Either add the data to storage, or stop getting data 
00262     // if the recorder has received the amount specified.
00263     if ( m_index < m_numData ) {
00264         m_data[m_index] = data;
00265         ++m_index;
00266         return false;
00267     }
00268     else {
00269         return true;
00270     }
00271 }

HDSchedulerHandle SensAble_hduRecorder::GetShedulerHandle (  )  [inline]

Definition at line 98 of file TAPsSensAble_hduRecord.cpp.

00098 { return m_hdSchedulerHandle; }

HDboolean SensAble_hduRecorder::Start (  ) 

Definition at line 152 of file TAPsSensAble_hduRecord.cpp.

00153 {
00154     m_hdSchedulerHandle = hdScheduleAsynchronous(
00155         SensAble_RecordLoopCallback,
00156         this,
00157         HD_MIN_SCHEDULER_PRIORITY
00158     );
00159     return ( m_hdSchedulerHandle == HD_INVALID_HANDLE ? false : true );
00160 }

void SensAble_hduRecorder::WriteDataToFile (  ) 

Definition at line 175 of file TAPsSensAble_hduRecord.cpp.

00176 {
00177     //*
00178     //---------------------------------------------------------------
00179     // Without data names
00180     for ( int i = 0; i < m_numData; ++i ) {
00181         SensAble_hduRecorderPacket & data = m_data[i];
00182         fprintf( m_file, "%d\t", i );
00183         fprintf( m_file, "%f %f %f\t", 
00184                 data.m_force[0],
00185                 data.m_force[1],
00186                 data.m_force[2] );
00187         fprintf( m_file,"%f %f %f\t", 
00188                 data.m_position[0],
00189                 data.m_position[1],
00190                 data.m_position[2] );
00191         fprintf( m_file, "%f %f %f\t", 
00192                 data.m_velocity[0],
00193                 data.m_velocity[1],
00194                 data.m_velocity[2] );
00195         fprintf( m_file,"%s\n",data.m_userData );
00196     }
00197     //*/
00198     /*
00199     //---------------------------------------------------------------
00200     // With data names
00201     for ( int i = 0; i < m_numData; ++i ) {
00202         SensAble_hduRecorderPacket & data = m_data[i];
00203         fprintf( m_file, "%d\t", i );
00204         fprintf( m_file, "Force: %f %f %f\t\t", 
00205                 data.m_force[0],
00206                 data.m_force[1],
00207                 data.m_force[2] );
00208         fprintf( m_file,"Position: %f %f %f\t\t", 
00209                 data.m_position[0],
00210                 data.m_position[1],
00211                 data.m_position[2] );
00212         fprintf( m_file, "Velocity: %f %f %f\t\t", 
00213                 data.m_velocity[0],
00214                 data.m_velocity[1],
00215                 data.m_velocity[2] );
00216         fprintf( m_file,"%s\n",data.m_userData );
00217     }
00218     //*/
00219 }


Member Data Documentation

Definition at line 111 of file TAPsSensAble_hduRecord.cpp.

Definition at line 108 of file TAPsSensAble_hduRecord.cpp.

HDSchedulerHandle SensAble_hduRecorder::m_hdSchedulerHandle [private]

Definition at line 114 of file TAPsSensAble_hduRecord.cpp.

Definition at line 110 of file TAPsSensAble_hduRecord.cpp.

Definition at line 109 of file TAPsSensAble_hduRecord.cpp.

SensAble_HDURecordCallback* SensAble_hduRecorder::m_pUserCallback [private]

Definition at line 106 of file TAPsSensAble_hduRecord.cpp.

Definition at line 107 of file TAPsSensAble_hduRecord.cpp.


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

Generated on Mon Oct 13 11:45:54 2008 for TAPs by  doxygen 1.5.6