INTRODUCTION Overview Download and Install Documentation Publications REPOSITORY Libraries DEVELOPER Dev Guide Dashboard PEOPLE Contributors Users Project Download Mailing lists
|
gbxgarminacfr/driver.h00001 /* 00002 * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics 00003 * http://gearbox.sf.net/ 00004 * Copyright (c) 2004-2008 Duncan Mercer, Alex Brooks, Alexei Makarenko, Tobias Kaupp 00005 * 00006 * This distribution is licensed to you under the terms described in 00007 * the LICENSE file included in this distribution. 00008 * 00009 */ 00010 00011 #ifndef GBXGARMINACFR_DRIVER_H 00012 #define GBXGARMINACFR_DRIVER_H 00013 00014 #include <gbxserialacfr/serial.h> 00015 #include <gbxutilacfr/tracer.h> 00016 #include <gbxutilacfr/status.h> 00017 #include <memory> 00018 00019 namespace gbxgarminacfr { 00020 00022 class Config 00023 { 00024 public: 00025 Config() : 00026 readGga(true), 00027 readVtg(true), 00028 readRme(true), 00029 ignoreUnknown(false) {}; 00030 00034 bool isValid() const; 00035 00037 std::string toString() const; 00038 00040 std::string device; 00041 00043 bool readGga; 00045 bool readVtg; 00047 bool readRme; 00048 00052 bool ignoreUnknown; 00053 }; 00054 00056 enum DataType 00057 { 00059 GpGga, 00061 GpVtg, 00063 PgRme 00064 }; 00065 00067 class GenericData 00068 { 00069 public: 00070 virtual ~GenericData() {}; 00072 virtual DataType type() const=0; 00073 00074 private: 00075 }; 00076 00078 enum FixType 00079 { 00081 Invalid, 00084 Autonomous, 00086 Differential 00087 }; 00088 00091 struct GgaData : public GenericData 00092 { 00093 public: 00094 DataType type() const { return GpGga; } 00095 00098 int timeStampSec; 00101 int timeStampUsec; 00102 00105 int utcTimeHrs; 00108 int utcTimeMin; 00111 double utcTimeSec; 00112 00114 double latitude; 00116 double longitude; 00118 double altitude; 00119 00122 FixType fixType; 00123 00125 int satellites; 00126 00128 double horizontalDilutionOfPosition; 00129 00131 double geoidalSeparation; 00132 }; 00133 00135 class VtgData : public GenericData 00136 { 00137 public: 00138 DataType type() const { return GpVtg; } 00139 00142 int timeStampSec; 00145 int timeStampUsec; 00146 00148 double headingTrue; 00150 double headingMagnetic; 00152 double speed; 00153 }; 00154 00156 class RmeData : public GenericData 00157 { 00158 public: 00159 DataType type() const { return PgRme; } 00160 00163 int timeStampSec; 00166 int timeStampUsec; 00167 00169 double horizontalPositionError; 00171 double verticalPositionError; 00172 00174 double estimatedPositionError; 00175 }; 00176 00198 class Driver 00199 { 00200 00201 public: 00202 00208 Driver( const Config& config, 00209 gbxutilacfr::Tracer& tracer, 00210 gbxutilacfr::Status& status ); 00211 00212 ~Driver(); 00213 00230 std::auto_ptr<GenericData> read(); 00231 00232 private: 00233 00234 void init(); 00235 void enableDevice(); 00236 void disableDevice(); 00237 00238 std::auto_ptr<gbxserialacfr::Serial> serial_; 00239 00240 Config config_; 00241 gbxutilacfr::Tracer& tracer_; 00242 gbxutilacfr::Status& status_; 00243 }; 00244 00245 } // namespace 00246 00247 #endif |