QGIS API Documentation
2.0.1-Dufour
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
src
core
gps
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
{
34
clearLastGPSInformation
();
35
QObject::connect
( dev, SIGNAL( readyRead() ),
this
, SLOT(
parseData
() ) );
36
}
37
38
QgsGPSConnection::~QgsGPSConnection
()
39
{
40
cleanupSource
();
41
}
42
43
bool
QgsGPSConnection::connect
()
44
{
45
if
( !
mSource
)
46
{
47
return
false
;
48
}
49
50
bool
connected =
mSource
->open( QIODevice::ReadWrite | QIODevice::Unbuffered );
51
if
( connected )
52
{
53
mStatus
=
Connected
;
54
}
55
return
connected;
56
}
57
58
bool
QgsGPSConnection::close
()
59
{
60
if
( !
mSource
)
61
{
62
return
false
;
63
}
64
65
mSource
->close();
66
return
true
;
67
}
68
69
void
QgsGPSConnection::cleanupSource
()
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;
83
clearLastGPSInformation
();
84
}
85
86
void
QgsGPSConnection::clearLastGPSInformation
()
87
{
88
mLastGPSInformation
.
direction
= 0;
89
mLastGPSInformation
.
elevation
= 0;
90
mLastGPSInformation
.
hdop
= 0;
91
mLastGPSInformation
.
latitude
= 0;
92
mLastGPSInformation
.
longitude
= 0;
93
mLastGPSInformation
.
pdop
= 0;
94
mLastGPSInformation
.
satellitesInView
.clear();
95
mLastGPSInformation
.
speed
= 0;
96
mLastGPSInformation
.
vdop
= 0;
97
mLastGPSInformation
.
hacc
= -1;
98
mLastGPSInformation
.
vacc
= -1;
99
mLastGPSInformation
.
quality
= -1;
// valid values: 0,1,2, maybe others
100
mLastGPSInformation
.
satellitesUsed
= 0;
101
mLastGPSInformation
.
fixMode
=
' '
;
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() );
107
mLastGPSInformation
.
satInfoComplete
=
false
;
108
}
Generated on Tue Sep 24 2013 14:41:46 for QGIS API Documentation by
1.8.1.2