connect(myLogin,SIGNAL(userNameChanged()),this,SLOT(userLogin()));
myRoute = new RouteDialog( this);
+ //GPS
+ location = new Maemo5Location(this);
+ gpsData = new GPSData(location);
+ connect(location,SIGNAL(agnss()),this,SLOT(gpsStatus()));
+
time = 0;
speed = 0;
timer = new QTimer();
}
/**
- *Destructor of this class. Should be used to release all allocated resources.
+ *Destructor of this class. Deletes all dynamic objects and sets them to NULL.
*/
CarMainWindow::~CarMainWindow()
{
delete ui;
+ ui = NULL;
//delete result;
//delete measure;
delete categorylist;
+ categorylist = NULL;
delete welcomeDialog;
+ welcomeDialog = NULL;
delete myRoute;
+ myRoute = NULL;
+ delete gpsData;
+ gpsData = NULL;
}
/**
{
myHttpClient->checkLogin();
}
+
+/**
+ *This slot function is called when GPS on checkbox state changed. Route-tab view.
+ *@param int GPSState
+ */
+void CarMainWindow::on_gpsOnCheckBox_stateChanged(int GPSState)
+{
+ if (GPSState == 0)
+ {
+ ui->labelRouteTabGPSStatus->setText("GPS off");//testing
+ location->stopPollingGPS();
+ }
+ else
+ {
+ ui->labelRouteTabGPSStatus->setText("GPS on");//testing
+ location->startPollingGPS();
+ }
+}
+
+/**
+ *This slot function is called when GPS status changed. Route-tab view.
+ */
+void CarMainWindow::gpsStatus()
+{
+ if (ui->gpsOnCheckBox->isChecked())
+ {
+ if (location->getSatellitesInUse() >= 4)
+ {
+ ui->labelRouteTabGPSStatus->setText("GPS ready");
+ }
+
+ else
+ {
+ ui->labelRouteTabGPSStatus->setText("Waiting for GPS");
+ }
+ }
+}
#include "categorylist.h"
#include "httpclient.h"
#include "routedialog.h"
+#include "gpsdata.h"
+#include <maemo5location.h>
namespace Ui {
class CarMainWindow;
HttpClient *myHttpClient;
LoginWindow *myLogin;
RouteDialog *myRoute;
+ GPSData *gpsData;
+ Maemo5Location *location;
//void initCategoryCompoBox();
void initComboBoxStartTabUnits(); //Start-tab view
void initListViewStartTabAccelerationCategories(); //Start-tab view
void userNameChanged();
private slots:
+ void on_gpsOnCheckBox_stateChanged(int GPSState); //Route-tab view
+ void gpsStatus(); //Route-tab view
void on_drawRoutePushButton_clicked();
void on_pushButtonSendResult_clicked();
void on_pushButtonMeasureTabAbort_clicked();
<string>Draw route</string>
</property>
</widget>
+ <widget class="QWidget" name="">
+ <property name="geometry">
+ <rect>
+ <x>310</x>
+ <y>16</y>
+ <width>221</width>
+ <height>211</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="labelRouteTabGPSStatus">
+ <property name="text">
+ <string>Label GPS Status</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="labelRouteTabLatitude">
+ <property name="text">
+ <string>Label Latitude</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="labelRouteTabLongitude">
+ <property name="text">
+ <string>Label Longitude</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
</widget>
</widget>
<widget class="QPushButton" name="registratePushButton">
/**
*Default constructor of this class.
*/
-GPSData::GPSData()
+GPSData::GPSData(Maemo5Location *maemo5location)
{
- location = new Maemo5Location(this);
+ location = maemo5location;
connect(location,SIGNAL(agnss()),this,SLOT(agnss()));
connect(location,SIGNAL(awcp()),this,SLOT(awcp()));
QString satellitesInUse = QString::number(location->getSatellitesInUse()); //Returns number of satellites in use.
QString satellitesInView = QString::number(location->getSatellitesInView());//Returns number of satellites in view.
QString signalStrength = QString::number(location->getSignalStrength()); //Returns average signal strength of satellites which are in use.
+ QString gpsOnline = QString::number(location->getGpsOnline()); //Returns gsp online
QString latitude = QString::number(location->getLatitude()); //Returns latitude.
QString longitude = QString::number(location->getLongitude()); //Returns longitude.
QString time = QString::number(location->getTime()); //Returns timestamp of the update in seconds.
class GPSData : public QObject
{
+ Q_OBJECT
public:
- GPSData();
+ GPSData(Maemo5Location *maemo5location);
~GPSData();
private:
{
ptr = new Maemo5LocationPrivate(this);
- connect(ptr,SIGNAL(agnss()),this,SIGNAL(agnss()));
- connect(ptr,SIGNAL(awcp()),this,SIGNAL(awcp()));
- connect(ptr,SIGNAL(locationUpdated()),this,SIGNAL(locationUpdated()));
+ connect(ptr, SIGNAL(agnss()), this, SIGNAL(agnss()));
+ connect(ptr, SIGNAL(awcp()), this, SIGNAL(awcp()));
+ connect(ptr, SIGNAL(locationUpdated()), this, SIGNAL(locationUpdated()));
connect(ptr, SIGNAL(gps_connected()), this, SIGNAL(gps_connected()));
connect(ptr, SIGNAL(gps_disconnected()), this, SIGNAL(gps_disconnected()));
connect(ptr, SIGNAL(gps_err(int)), this, SIGNAL(gps_error(int)));
connect(ptr, SIGNAL(gpsd_running()), this, SIGNAL(gpsd_running()));
- connect(ptr, SIGNAL(gpsd_stopped()), this, SIGNAL(gpsd_stopped()));
-
- ptr->get_agnss();
+ connect(ptr, SIGNAL(gpsd_stopped()), this, SIGNAL(gpsd_stopped()));
}
/**
}
/**
- *Returns latitude.
+ *Start polling gps.
*/
-double Maemo5Location::getLatitude()
+void Maemo5Location::startPollingGPS()
{
- return ptr->get_lat();
+ ptr->get_agnss();
}
/**
- *Returns longitude.
+ *Stop polling gps.
*/
-double Maemo5Location::getLongitude()
+void Maemo5Location::stopPollingGPS()
{
- return ptr->get_lon();
+ ptr->stop();
}
/**
}
/**
+ *Returns gps online.
+ */
+bool Maemo5Location::getGpsOnline()
+{
+ return ptr->get_gps_online();
+}
+
+/**
+ *Returns latitude.
+ */
+double Maemo5Location::getLatitude()
+{
+ return ptr->get_lat();
+}
+
+/**
+ *Returns longitude.
+ */
+double Maemo5Location::getLongitude()
+{
+ return ptr->get_lon();
+}
+
+/**
*Returns timestamp of the update in seconds.
*/
double Maemo5Location::getTime()
Maemo5Location(QObject* parent = 0);
~Maemo5Location();
+ void startPollingGPS();
+ void stopPollingGPS();
int getSatellitesInUse();
int getSatellitesInView();
int getSignalStrength();
+ bool getGpsOnline();
double getLatitude();
double getLongitude();
double getTime();
}
/**
- *Stop pollling
+ *Stop polling gps
*/
void Maemo5LocationPrivate::stop()
{
gps->satellites_in_use = gps->device->satellites_in_use;
gps->satellites_in_view = gps->device->satellites_in_view;
- if(gps->device->fix->fields & LOCATION_GPS_DEVICE_TIME_SET)
+ if(gps->device->fix->fields & LOCATION_GPS_DEVICE_TIME_SET)
{
gps->time = gps->device->fix->time;
gps->ept = gps->device->fix->ept;
{
for(int i=0 ; i < gps->satellites_in_use ; i++)
{
- LocationGPSDeviceSatellite * view = (LocationGPSDeviceSatellite*) g_ptr_array_index (gps->device->satellites, i);
+ LocationGPSDeviceSatellite *view = (LocationGPSDeviceSatellite*) g_ptr_array_index (gps->device->satellites, i);
temp = temp + view->signal_strength;
}
gps->signal_strength = (temp / gps->satellites_in_use);
double get_climb() { return climb; }
double get_epc() { return epc; }
double distance_between_two_points(double latitude_s, double longitude_s, double latitude_f, double longitude_f);
+ void stop();
signals:
void awcp();
private:
void resetAll();
- void stop();
+ //void stop();
void restart();
int satellites_in_view;