Fast Research Interface Library  Manual and Documentation
src/FastResearchInterfaceLibrary/ReadInitFile.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 <Console.h>
00058 #include <errno.h>
00059 #include <string.h>
00060 #include <InitializationFileEntry.h>
00061 #include <OSAbstraction.h>
00062 
00063 
00064 // ****************************************************************
00065 // ReadInitFile()
00066 //
00067 int FastResearchInterface::ReadInitFile(const char *InitFileName)
00068 {
00069     unsigned int                ParameterCount              =   0;
00070 
00071     InitializationFileEntry     InitFileParser(InitFileName);
00072 
00073     if (InitFileName != NULL)
00074     {
00075         while ( InitFileParser.NextEntry() )
00076         {
00077             if ( !stricmp (InitFileParser.GetSection(), "Priorities") )
00078             {
00079                 if ( !stricmp (InitFileParser.GetName(), "KRCCommunicationThread") )
00080                 {
00081                     this->PriorityKRCCommunicationThread = atoi( InitFileParser.GetValue() );
00082                     ParameterCount++;
00083                 }
00084                 if ( !stricmp (InitFileParser.GetName(), "TimerThread") )
00085                 {
00086                     this->PriorityTimerThread = atoi( InitFileParser.GetValue() );
00087                     ParameterCount++;
00088                 }
00089                 if ( !stricmp (InitFileParser.GetName(), "MainThread") )
00090                 {
00091                     this->PriorityMainThread = atoi( InitFileParser.GetValue() );
00092                     ParameterCount++;
00093                 }
00094                 if ( !stricmp (InitFileParser.GetName(), "OutputConsoleThread") )
00095                 {
00096                     this->PriorityOutputConsoleThread = atoi( InitFileParser.GetValue() );
00097                     ParameterCount++;
00098                 }
00099             }
00100             if ( !stricmp (InitFileParser.GetSection(), "RobotName") )
00101             {
00102                 if ( !stricmp (InitFileParser.GetName(), "Name") )
00103                 {
00104                     strcpy(this->RobotName, InitFileParser.GetValue() );
00105                     ParameterCount++;
00106                 }
00107             }
00108 
00109             if ( !stricmp (InitFileParser.GetSection(), "ControlValues") )
00110             {
00111                 if ( !stricmp (InitFileParser.GetName(), "CycleTime") )
00112                 {
00113                     this->CycleTime = atof( InitFileParser.GetValue() );
00114                     ParameterCount++;
00115                 }
00116             }
00117 
00118             if ( !stricmp (InitFileParser.GetSection(), "Logging") )
00119             {
00120                 if ( !stricmp (InitFileParser.GetName(), "NumberOfLoggingFileEntries") )
00121                 {
00122                     NumberOfLoggingFileEntries = atoi( InitFileParser.GetValue() );
00123                     ParameterCount++;
00124                 }
00125                 if ( !stricmp (InitFileParser.GetName(), "LoggingPath") )
00126                 {
00127                     strcpy(this->LoggingPath, InitFileParser.GetValue() );
00128                     ParameterCount++;
00129                 }
00130                 if ( !stricmp (InitFileParser.GetName(), "LoggingFileName") )
00131                 {
00132                     strcpy(this->LoggingFileName, InitFileParser.GetValue() );
00133                     ParameterCount++;
00134                 }
00135             }
00136         }
00137     }
00138     else
00139     {
00140         return(-1);
00141     }
00142 
00143     return(ParameterCount);
00144 
00145 }
00146 
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.