Fast Research Interface Library  Manual and Documentation
src/FastResearchInterfaceLibrary/LoggingMethods.cpp
Go to the documentation of this file.
00001 //  ---------------------- Doxygen info ----------------------
00050 //  ----------------------------------------------------------
00051 //   For a convenient reading of this file's source code,
00052 //   please use a tab width of four characters.
00053 //  ----------------------------------------------------------
00054 
00055 
00056 #include <FastResearchInterface.h>
00057 #include <DataLogging.h>
00058 #include <errno.h>
00059 #include <OSAbstraction.h>
00060 
00061 
00062 // ****************************************************************
00063 // PrepareLogging()
00064 //
00065 int FastResearchInterface::PrepareLogging(const char *FileIdentifier)
00066 {
00067     if (this->LoggingState != FastResearchInterface::WriteLoggingDataFileCalled)
00068     {
00069         return(EINVAL);
00070     }
00071     else
00072     {
00073         this->LoggingState = FastResearchInterface::PrepareLoggingCalled;
00074     }
00075 
00076     return(this->DataLogger->PrepareLogging(this->CurrentControlScheme, FileIdentifier));
00077 }
00078 
00079 
00080 // ****************************************************************
00081 // StartLogging()
00082 //
00083 int FastResearchInterface::StartLogging(void)
00084 {
00085     if (this->LoggingState != FastResearchInterface::PrepareLoggingCalled)
00086     {
00087         return(EINVAL);
00088     }
00089     else
00090     {
00091         this->LoggingState = FastResearchInterface::StartLoggingCalled;
00092     }
00093 
00094     pthread_mutex_lock(&(this->MutexForLogging));
00095     this->LoggingIsActive   =   true;
00096     pthread_mutex_unlock(&(this->MutexForLogging));
00097 
00098     return(EOK);
00099 }
00100 
00101 
00102 // ****************************************************************
00103 // StopLogging()
00104 //
00105 int FastResearchInterface::StopLogging(void)
00106 {
00107     if (this->LoggingState != FastResearchInterface::StartLoggingCalled)
00108     {
00109         return(EINVAL);
00110     }
00111     else
00112     {
00113         this->LoggingState = FastResearchInterface::StopLoggingCalled;
00114     }
00115 
00116     pthread_mutex_lock(&(this->MutexForLogging));
00117     this->LoggingIsActive   =   false;
00118     pthread_mutex_unlock(&(this->MutexForLogging));
00119 
00120     return(EOK);
00121 }
00122 
00123 
00124 // ****************************************************************
00125 // WriteLoggingDataFile()
00126 //
00127 int FastResearchInterface::WriteLoggingDataFile(void)
00128 {
00129     if (this->LoggingState == FastResearchInterface::WriteLoggingDataFileCalled)
00130     {
00131         return(EINVAL);
00132     }
00133 
00134     this->LoggingState = FastResearchInterface::WriteLoggingDataFileCalled;
00135 
00136     if (this->LoggingState == FastResearchInterface::StartLoggingCalled)
00137     {
00138         pthread_mutex_lock(&(this->MutexForLogging));
00139         this->LoggingIsActive   =   false;
00140         pthread_mutex_unlock(&(this->MutexForLogging));
00141     }
00142 
00143     return(this->DataLogger->WriteToFile());
00144 }
00145 
This document was generated with Doxygen on Thu Apr 12 2012 11:18:54. User documentation of the Fast Research Interface Library for the KUKA Lightweight Robot IV by the Stanford Robotics Research Group. Copyright 2010–2012.