Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

ArDataLogger.h

00001 /*
00002 ActivMedia Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004,2005 ActivMedia Robotics, LLC
00004 
00005 
00006      This program is free software; you can redistribute it and/or modify
00007      it under the terms of the GNU General Public License as published by
00008      the Free Software Foundation; either version 2 of the License, or
00009      (at your option) any later version.
00010 
00011      This program is distributed in the hope that it will be useful,
00012      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014      GNU General Public License for more details.
00015 
00016      You should have received a copy of the GNU General Public License
00017      along with this program; if not, write to the Free Software
00018      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 If you wish to redistribute ARIA under different terms, contact 
00021 ActivMedia Robotics for information about a commercial version of ARIA at 
00022 robots@activmedia.com or 
00023 ActivMedia Robotics, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
00024 
00025 */
00026 
00027 #ifndef ARDATALOGGER_H
00028 #define ARDATALOGGER_H
00029 
00030 #include "ariaUtil.h"
00031 #include "ArMutex.h"
00032 #include <vector>
00033 
00034 class ArRobot;
00035 class ArConfig;
00036 
00037 
00039 
00043 class ArDataLogger
00044 {
00045 public:
00046   ArDataLogger(ArRobot *robot, const char *fileName = NULL);
00047   ~ArDataLogger();
00048   void addToConfig(ArConfig *config);
00049 
00051   void addString(const char *name, ArTypes::UByte2 maxLen, 
00052                           ArFunctor2<char *, ArTypes::UByte2> *functor);
00053 
00055   void addStringInt(const char *name, ArTypes::UByte2 maxLen, 
00056                              ArRetFunctor<int> *functor, 
00057                              const char *format = "%d");
00058 
00060   void addStringDouble(const char *name, ArTypes::UByte2 maxLen, 
00061                                 ArRetFunctor<double> *functor, 
00062                                 const char *format = "%g");
00063 
00065   void addStringBool(const char *name, ArTypes::UByte2 maxLen, 
00066                               ArRetFunctor<bool> *functor,
00067                               const char *format = "%s");
00068 
00070   void addStringString(const char *name, ArTypes::UByte2 maxLen, 
00071                               ArRetFunctor<const char *> *functor,
00072                               const char *format = "%s");
00073 
00074 protected:
00075   void connectCallback(void);
00076   bool processFile(char *errorBuffer, size_t errorBufferLen);
00077   void userTask(void);
00078   ArRobot *myRobot;
00079   ArTime myLastLogged;
00080   ArConfig *myConfig;
00081   bool myAddToConfigAtConnect;
00082   bool myAddedToConfig;
00083 
00084   FILE *myFile;
00085   bool myConfigLogging;
00086   int myConfigLogInterval;
00087   char myOpenedFileName[512];
00088   char myConfigFileName[512];
00089   std::string myPermanentFileName;
00090 
00091   // for what we're logging
00092   bool myLogVoltage;
00093   bool myLogLeftVel;
00094   bool myLogRightVel;
00095   bool myLogTransVel;
00096   bool myLogRotVel;
00097   bool myLogLeftStalled;
00098   bool myLogRightStalled;
00099   bool myLogStallBits;
00100   bool myLogFlags;
00101   int myAnalogCount;
00102   bool *myAnalogEnabled;
00103   int myAnalogVoltageCount;
00104   bool *myAnalogVoltageEnabled;
00105   int myDigInCount;
00106   bool *myDigInEnabled;
00107   int myDigOutCount;
00108   bool *myDigOutEnabled;
00109   bool myLogPose;
00110   bool myLogEncoderPose;
00111   bool myLogCorrectedEncoderPose;
00112   bool myLogEncoders;
00113   int myStringsCount;
00114   bool *myStringsEnabled;
00115   ArMutex myMutex;
00116 
00117   std::vector<ArStringInfoHolder *> myStrings;
00118   ArTypes::UByte2 myMaxMaxLength;
00119   
00120   ArFunctorC<ArDataLogger> myConnectCB;  
00121   ArRetFunctor2C<bool, ArDataLogger, char *, size_t> myProcessFileCB;
00122   ArFunctorC<ArDataLogger> myUserTaskCB;
00123 };
00124 
00125 #endif // ARDATALOGGER_H

Generated on Wed Oct 19 12:56:34 2005 for Aria by  doxygen 1.4.0