00001 /*************************************************************************** 00002 ** 00003 ** This file is part of warangps. 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-06-27 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 <QtNetwork> 00031 #include <QGpCoreTools.h> 00032 #include <WaranCore.h> 00033 00034 class GpsStation : public QObject 00035 { 00036 Q_OBJECT 00037 public: 00038 GpsStation(); 00039 ~GpsStation(); 00040 00041 QString name() const {return _name;} 00042 void setName(QString n) {_name=n;} 00043 00044 QString operatorName() const {return _operatorName;} 00045 void setOperatorName(QString o) {_operatorName=o;} 00046 00047 QString hostName() const {return _hostName;} 00048 void setHostName(QString hn) {_hostName=hn;} 00049 00050 quint16 port() const {return _port;} 00051 void setPort(quint16 p) {_port=p;} 00052 00053 QString solution() const; 00054 const QString& info() const {return _info;} 00055 const Statistics& longitude() const {return _longitude;} 00056 const Statistics& latitude() const {return _latitude;} 00057 const Statistics& altitude() const {return _altitude;} 00058 double horizontalAccuracy() const {return _fix.horizontalAccuracy()*1e-3;} 00059 double horizontalDop() const {return _fix.horizontalDop()*1e-2;} 00060 double northingDop() const {return _fix.northingDop()*1e-2;} 00061 double eastingDop() const {return _fix.eastingDop()*1e-2;} 00062 int sateliteCount() const {return _fix.sateliteCount();} 00063 const Point& coordinates() const {return _coordinates;} 00064 00065 bool isAvailable(); 00066 00067 void startBroadcast(); 00068 void stopBroadcast(); 00069 00070 enum Mode {Track, Stack}; 00071 void setMode(Mode m); 00072 Mode mode() const {return _mode;} 00073 private slots: 00074 void bytesAvailable(); 00075 void justConnected(); 00076 signals: 00077 void modeChanged(); 00078 private: 00079 bool match(const char * buffer, int& bytesRead, int bytesCount, const char * string); 00080 int readInteger(const char * buffer, int& bytesRead, int bytesCount, bool& ok); 00081 int bytesAvailable(const char * buffer, int bytesCount); 00082 bool parseFix(const char * data, int bytesCount); 00083 00084 QString _name; 00085 QString _hostName; 00086 quint16 _port; 00087 QString _operatorName; 00088 Statistics _longitude; 00089 Statistics _latitude; 00090 Statistics _altitude; 00091 GpsFix _fix; 00092 Point _coordinates; 00093 Mode _mode; 00094 QString _info; 00095 QTcpSocket _socket; 00096 QGpCoreTools::DynamicBuffer _socketBuffer; 00097 unsigned char _index; 00098 }; 00099 00100 #endif // GPSSTATION_H 00101