00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef ARDATALOGGER_H
00027 #define ARDATALOGGER_H
00028
00029 #include "ariaUtil.h"
00030 #include "ArMutex.h"
00031 #include "ArFunctor.h"
00032 #include <vector>
00033
00034 class ArRobot;
00035 class ArConfig;
00036
00037
00039
00046 class ArDataLogger
00047 {
00048 public:
00050 AREXPORT ArDataLogger(ArRobot *robot, const char *fileName = NULL);
00052 AREXPORT ~ArDataLogger();
00054 AREXPORT void addToConfig(ArConfig *config);
00056 AREXPORT void addString(const char *name, ArTypes::UByte2 maxLen,
00057 ArFunctor2<char *, ArTypes::UByte2> *functor);
00058
00060 ArFunctor3<const char *, ArTypes::UByte2,
00061 ArFunctor2<char *, ArTypes::UByte2> *> *
00062 getAddStringFunctor(void) { return &myAddStringFunctor; }
00063
00064 protected:
00065 AREXPORT void connectCallback(void);
00066 AREXPORT bool processFile(char *errorBuffer, size_t errorBufferLen);
00067 AREXPORT void userTask(void);
00068 ArRobot *myRobot;
00069 ArTime myLastLogged;
00070 ArConfig *myConfig;
00071 bool myAddToConfigAtConnect;
00072 bool myAddedToConfig;
00073
00074 FILE *myFile;
00075 bool myConfigLogging;
00076 int myConfigLogInterval;
00077 char myOpenedFileName[512];
00078 char myConfigFileName[512];
00079 std::string myPermanentFileName;
00080
00081
00082 bool myLogVoltage;
00083 bool myLogLeftVel;
00084 bool myLogRightVel;
00085 bool myLogTransVel;
00086 bool myLogRotVel;
00087 bool myLogLeftStalled;
00088 bool myLogRightStalled;
00089 bool myLogStallBits;
00090 bool myLogFlags;
00091 int myAnalogCount;
00092 bool *myAnalogEnabled;
00093 int myAnalogVoltageCount;
00094 bool *myAnalogVoltageEnabled;
00095 int myDigInCount;
00096 bool *myDigInEnabled;
00097 int myDigOutCount;
00098 bool *myDigOutEnabled;
00099 bool myLogPose;
00100 bool myLogEncoderPose;
00101 bool myLogCorrectedEncoderPose;
00102 bool myLogEncoders;
00103 int myStringsCount;
00104 std::vector<bool *> myStringsEnabled;
00105 ArMutex myMutex;
00106
00107 std::vector<ArStringInfoHolder *> myStrings;
00108 ArTypes::UByte2 myMaxMaxLength;
00109 ArFunctor3C<ArDataLogger, const char *, ArTypes::UByte2,
00110 ArFunctor2<char *, ArTypes::UByte2> *> myAddStringFunctor;
00111
00112
00113 ArFunctorC<ArDataLogger> myConnectCB;
00114 ArRetFunctor2C<bool, ArDataLogger, char *, size_t> myProcessFileCB;
00115 ArFunctorC<ArDataLogger> myUserTaskCB;
00116 };
00117
00118 #endif // ARDATALOGGER_H