00001 /*************************************************************************** 00002 ** 00003 ** This file is part of warangpsd. 00004 ** 00005 ** This file may be distributed and/or modified under the terms of the 00006 ** GNU General Public License version 2 or 3 as published by the Free 00007 ** Software Foundation and appearing in the file LICENSE.GPL included 00008 ** in the packaging of this file. 00009 ** 00010 ** This file is distributed in the hope that it will be useful, but WITHOUT 00011 ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 00013 ** more details. 00014 ** 00015 ** You should have received a copy of the GNU General Public License 00016 ** along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 ** 00018 ** See http://www.geopsy.org for more information. 00019 ** 00020 ** Created : 2009-09-10 00021 ** Authors: 00022 ** Marc Wathelet 00023 ** Marc Wathelet (LGIT, Grenoble, France) 00024 ** 00025 ***************************************************************************/ 00026 00027 #ifndef GPSSTATION_H 00028 #define GPSSTATION_H 00029 00030 #include <GpCoreTools.h> 00031 #include <WaranCore.h> 00032 00033 class GpsStation 00034 { 00035 public: 00036 GpsStation(); 00037 ~GpsStation(); 00038 00039 const Address& address() const {return _address;} 00040 void setAddress(const Address& a) {_address=a;} 00041 00042 uint16_t port() const {return _port;} 00043 void setPort(uint16_t p) {_port=p;} 00044 00045 int fixCount() const {return _fixCount;} 00046 const std::string& info() const {return _info;} 00047 const Statistics& longitude() const {return _longitude;} 00048 const Statistics& latitude() const {return _latitude;} 00049 const Statistics& altitude() const {return _altitude;} 00050 double horizontalAccuracy() const {return _fix.horizontalAccuracy()*1e-3;} 00051 double horizontalDop() const {return _fix.horizontalDop()*1e-2;} 00052 double northingDop() const {return _fix.northingDop()*1e-2;} 00053 double eastingDop() const {return _fix.eastingDop()*1e-2;} 00054 int sateliteCount() const {return _fix.sateliteCount();} 00055 00056 bool isAvailable(); 00057 00058 void startBroadcast(); 00059 void stopBroadcast(); 00060 void powerOn(); 00061 void powerOff(); 00062 void requestInfo(); 00063 00064 enum Mode {Off, Track, Stack}; 00065 void setMode(Mode m); 00066 Mode mode() const {return _mode;} 00067 private: 00068 int parseFix(const char * data, int bytesAvailable); 00069 int parseInfo(const char * data, int bytesAvailable); 00070 00071 Address _address; 00072 uint16_t _port; 00073 00074 Mode _mode; 00075 int _fixCount; 00076 Statistics _longitude; 00077 Statistics _latitude; 00078 Statistics _altitude; 00079 GpsFix _fix; 00080 std::string _info; 00081 }; 00082 00083 #endif // GPSSTATION_H