4 * @author Toni Jussila <toni.jussila@fudeco.com>
5 * @copyright (c) 2010 Speed Freak team
6 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12 *Default constructor of this class.
14 GPSData::GPSData(Maemo5Location *maemo5location)
16 location = maemo5location;
18 connect(location,SIGNAL(agnss()),this,SLOT(agnss()));
19 connect(location,SIGNAL(awcp()),this,SLOT(awcp()));
20 connect(location,SIGNAL(locationUpdated()),this,SLOT(locationUpdated()));
21 connect(location,SIGNAL(gps_connected()),this,SLOT(gpsConnected()));
22 connect(location,SIGNAL(gps_disconnected()),this,SLOT(gpsDisconnected()));
23 connect(location,SIGNAL(gps_error(int)),this,SLOT(gpsError()));
24 connect(location,SIGNAL(gpsd_running()),this,SLOT(gpsdRunning()));
25 connect(location,SIGNAL(gpsd_stopped()),this,SLOT(gpsdStopped()));
27 gpsTimer = new QTimer();
29 connect(gpsTimer, SIGNAL(timeout()),this, SLOT(gpsTimerTimeout()));
35 *Destructor of this class. Deletes all dynamic objects and sets them to NULL.
43 void GPSData::resetAll()
62 recordingStatus = false;
67 *This slot function is called when GPS update location.
71 //satellitesInUse = QString::number(location->getSatellitesInUse()); //Returns number of satellites in use.
72 //satellitesInView = QString::number(location->getSatellitesInView());//Returns number of satellites in view.
73 //signalStrength = QString::number(location->getSignalStrength()); //Returns average signal strength of satellites which are in use.
74 //gpsOnline = QString::number(location->getGpsOnline()); //Returns gsp online
75 //ept = QString::number(location->getEpt()); //Returns time accuracy in seconds.
76 //eph = QString::number(location->getEph()); //Returns horizontal position accuracy in cm.
77 //track = QString::number(location->getTrack()); //Returns direction of motion in degrees(0-359).
78 //epd = QString::number(location->getEpd()); //Returns track accuracy in degrees.
79 //climb = QString::number(location->getClimb()); //Returns current rate of climb in m/s.
80 //epc = QString::number(location->getEpc()); //Returns climb accuracy in m/s.
81 //location->distance_between_two_points(double latitude_s, double longitude_s, double latitude_f, double longitude_f);
82 //time = location->getTime();//Returns timestamp of the update in seconds.
84 //If route recording true
85 if ( recordingStatus == true )
87 latitude = location->getLatitude(); //Returns latitude.
88 longitude = location->getLongitude(); //Returns longitude.
89 altitude = location->getAltitude(); //Returns fix altitude in meters.
90 epv = location->getEpv(); //Returns altitude accuracy in meters.
91 speed = location->getSpeed(); //Returns current speed in km/h.
92 eps = location->getEps(); //Returns speed accuracy in km/h.
97 if (roundCounter == 0)
104 latitudeNow.sprintf("%.4f", latitude); //Latitude now to string
105 longitudeNow.sprintf("%.4f", longitude);//Longitude now to string
106 latitudePrevious.sprintf("%.4f", gpsDataArray[0]); //Previous latitude to string
107 longitudePrevious.sprintf("%.4f", gpsDataArray[1]); //Previous longitude to string
109 //If latitude or longitude change
110 if ( latitudeNow != latitudePrevious || longitudeNow != longitudePrevious )
119 *This slot function is called when gprs update location.
127 *This slot function is called when .
129 void GPSData::locationUpdated()
135 *This slot function is called when .
137 void GPSData::gpsConnected()
143 *This slot function is called when .
145 void GPSData::gpsDisconnected()
151 *This slot function is called when .
153 void GPSData::gpsError()
159 *This slot function is called when .
161 void GPSData::gpsdRunning()
167 *This slot function is called when .
169 void GPSData::gpsdStopped()
175 *This function start route recording.
176 *@param QString time recording start time.
178 void GPSData::startRouteRecording(QString time)
180 if (recordingStatus == false)
182 routeStartTime = time;
183 recordingStatus = true;
189 *This function stop route recording.
190 *@param QString time recording stop time.
192 void GPSData::stopRouteRecording(QString time)
194 if (recordingStatus == true)
196 routeStopTime = time;
197 recordingStatus = false;
204 *This slot function is called when gps timer timeout(10s).
206 void GPSData::gpsTimerTimeout()
212 *This function save route to .txt file.
214 void GPSData::saveRoute()
216 QFile file("route" + routeStartTime + ".txt");
217 QTextStream route(&file);
219 if ( recordingStatus == true )
222 if ( roundCounter == 0 )
224 if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
227 route << "Start: " << routeStartTime << "\n";
232 if (!file.open(QIODevice::Append | QIODevice::Text))
236 gpsDataArray[0] = latitude;
237 gpsDataArray[1] = longitude;
238 gpsDataArray[2] = altitude;
239 gpsDataArray[3] = speed;
242 route << " la: " << latitude
243 << " \t lo: " << longitude
244 << " \t al: " << altitude
245 << " \t epv: " << epv
246 << " \t sp: " << speed
247 << " \t eps: " << eps
248 << " \t ms: " << gpsTimeMS
258 if (!file.open(QIODevice::Append | QIODevice::Text))
260 route << "Stop: " << routeStopTime << "\n";
266 *@return Pointer to gpsDataArray[][].
268 double* GPSData::getGpsDataArray()
270 return *gpsDataArray;
274 *@return RoundCounter, the number of gpsDataArray[][] rows.
276 int GPSData::getRoundCounter()