QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsgpsconnection.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsgpsconnection.cpp - description
3  --------------------
4  begin : November 30th, 2009
5  copyright : (C) 2009 by Marco Hugentobler
6  email : marco at hugis dot net
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "qgsgpsconnection.h"
19 
20 #include <QCoreApplication>
21 #include <QTime>
22 #include <QIODevice>
23 #include <QStringList>
24 #include <QFileInfo>
25 
26 #include "qextserialport.h"
27 #include "qextserialenumerator.h"
28 
29 #include "qgsnmeaconnection.h"
30 #include "qgslogger.h"
31 
32 QgsGPSConnection::QgsGPSConnection( QIODevice* dev ): QObject( 0 ), mSource( dev ), mStatus( NotConnected )
33 {
35  QObject::connect( dev, SIGNAL( readyRead() ), this, SLOT( parseData() ) );
36 }
37 
39 {
40  cleanupSource();
41 }
42 
44 {
45  if ( !mSource )
46  {
47  return false;
48  }
49 
50  bool connected = mSource->open( QIODevice::ReadWrite | QIODevice::Unbuffered );
51  if ( connected )
52  {
54  }
55  return connected;
56 }
57 
59 {
60  if ( !mSource )
61  {
62  return false;
63  }
64 
65  mSource->close();
66  return true;
67 }
68 
70 {
71  if ( mSource )
72  {
73  mSource->close();
74  }
75  delete mSource;
76  mSource = 0;
77 }
78 
79 void QgsGPSConnection::setSource( QIODevice* source )
80 {
81  cleanupSource();
82  mSource = source;
84 }
85 
87 {
99  mLastGPSInformation.quality = -1; // valid values: 0,1,2, maybe others
102  mLastGPSInformation.fixType = 0; // valid values: 1,2,3
103  mLastGPSInformation.status = ' '; // valid values: A,V
104  mLastGPSInformation.utcDateTime.setDate( QDate() );
105  mLastGPSInformation.satPrn.clear();
106  mLastGPSInformation.utcDateTime.setTime( QTime() );
108 }