Jean-Yves Didier

Mise au point de la bibliothèque GPS : tout est porté

......@@ -12,8 +12,9 @@ HEADERS += nmea.h
SOURCES += nmea.cpp
#The following line was changed from FORMS to FORMS3 by qt3to4
FORMS3 = gpswidget.ui
FORMS = gpswidget2.ui
HEADERS += gpswidget.h
HEADERS += gpswwidget.h
HEADERS += gpstracker.h
HEADERS += gpstranslator.h
......@@ -23,6 +24,7 @@ HEADERS += triggps.h
HEADERS += synsensor.h
HEADERS += synchro.h
SOURCES += gpswidget.cpp
SOURCES += gpstracker.cpp
SOURCES += gpstranslator.cpp
SOURCES += gpslog.cpp
......@@ -36,7 +38,7 @@ SOURCES+= gpsserial.cpp
SOURCES +=
MOC_DIR = ./moc
UI_DIR = ./ui
UI_DIR = .
OBJECTS_DIR = ./obj
......@@ -57,9 +59,9 @@ DEFINES += _CRT_SECURE_NO_DEPRECATE
unix: QMAKE_POST_LINK=mv *.so* ../../../libs
win32: DLLDESTDIR = ../../../libs
#The following line was inserted by qt3to4
QT += qt3support
#QT += qt3support
#The following line was inserted by qt3to4
CONFIG += uic3
CONFIG += uic
......
......@@ -12,20 +12,20 @@ void GPSLogger::setPath(QString s)
{
chemin=s;
ofstream file;
file.open(chemin.ascii());
file.open(qPrintable(chemin));
if (!file.is_open())
{
cerr << "Couldn't open file " << chemin.ascii() << endl;
cerr << "Couldn't open file " << qPrintable(chemin) << endl;
return;
}
}
void GPSLogger::setTimestamp(double t)
{
ofstream file;
file.open(chemin.ascii(),ios::app);
file.open(qPrintable(chemin),ios::app);
if (!file.is_open())
{
cerr << "Couldn't open file " << chemin.ascii() << endl;
cerr << "Couldn't open file " << qPrintable(chemin) << endl;
return;
}
file<<t<<endl;
......@@ -35,10 +35,10 @@ file.close();
void GPSLogger::setStartTime(double t)
{
ofstream file;
file.open(chemin.ascii(),ios::app);
file.open(qPrintable(chemin),ios::app);
if (!file.is_open())
{
cerr << "Couldn't open file " << chemin.ascii() << endl;
cerr << "Couldn't open file " << qPrintable(chemin) << endl;
return;
}
file<<t<<endl;
......@@ -48,10 +48,10 @@ file.close();
void GPSLogger::setNMEAFrame(NMEAFrame tram)
{
ofstream file;
file.open(chemin.ascii(),ios::app);
file.open(qPrintable(chemin),ios::app);
if (!file.is_open())
{
cerr << "Couldn't open file " << chemin.ascii() << endl;
cerr << "Couldn't open file " << qPrintable(chemin) << endl;
return;
}
/*CvScalar a;
......@@ -92,11 +92,11 @@ starttime = val;
void LoadGps::init()
{
cout<<"[Lgps]init path:"<<qPrintable(chemin)<<endl;
file.open(chemin.ascii());
file.open(qPrintable(chemin));
initialized = file.is_open();
if (!file.is_open())
{
cerr << "Couldn't open file " << chemin.ascii() << endl;
cerr << "Couldn't open file " << qPrintable(chemin) << endl;
return;
}
if(starttime=true)
......
......@@ -36,13 +36,13 @@ void GPSTracker::init()
#ifdef WIN32
if (!gps.openPort(port, (GPSSerial::BaudRates)computeRealBaudrate()))
#else
if (!gps.openPort(device.ascii(),(GPSSerial::BaudRates)computeRealBaudrate()))
if (!gps.openPort(qPrintable(device),(GPSSerial::BaudRates)computeRealBaudrate()))
#endif
{
#ifdef WIN32
std::cerr << "[GPS] Cannot access GPS. num port" << port << std::endl;
#else
std::cerr << "[GPS] Cannot access GPS. " << device.ascii() << std::endl;
std::cerr << "[GPS] Cannot access GPS. " << qPrintable(device) << std::endl;
#endif
return ;
......
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you want to add, delete, or rename functions or slots, use
** Qt Designer to update this file, preserving your code.
**
** You should not define a constructor or destructor in this file.
** Instead, write your code in functions called init() and destroy().
** These will automatically be called by the form's constructor and
** destructor.
*****************************************************************************/
/*! \class GPSWidget A simple widget to display GPS values
* \author Jean-Yves Didier
......@@ -17,14 +5,27 @@
* \ingroup gps
*/
#include "gpswidget.h"
#include "ui_gpswidget2.h"
GPSWidget::GPSWidget(QWidget* parent) : QWidget(parent), ui(new Ui::GPSWidget)
{
ui->setupUi(this);
}
GPSWidget::~GPSWidget()
{
delete ui;
}
/*! \brief This slot intends to display GPS values
* \param f A NMEAFrame containing GPS data.
*/
void GPSWidget::displayNMEAFrame( NMEAFrame f )
{
longitude->setText("-NC-");
latitude->setText("-NC-");
ui->longitude->setText("-NC-");
ui->latitude->setText("-NC-");
//std::cout<<f.getRawFrame()<<std::endl;
if (f.extractType() == "GGA")
......@@ -37,21 +38,21 @@ void GPSWidget::displayNMEAFrame( NMEAFrame f )
if (lon.valid)
{
QString llon = QString::number(lon.degrees) + "" + QString::number(lon.minutes) + "' " + lon.direction ;
longitude->setText(llon);
longitude->update();
ui->longitude->setText(llon);
ui->longitude->update();
std::cout<<"longitude "<<qPrintable(llon)<<std::endl;
}
if (lat.valid)
{
QString llat = QString::number(lat.degrees) + "" + QString::number(lat.minutes) + "' " + lat.direction ;
latitude->setText(llat);
latitude->update();
ui->latitude->setText(llat);
ui->latitude->update();
std::cout<<"latitude "<<qPrintable(llat)<<std::endl;
}
dop->setText(QString::number(frame.getDOP()));
dop->update();
sv->display(frame.getSVNumber());
ui->dop->setText(QString::number(frame.getDOP()));
ui->dop->update();
ui->sv->display(frame.getSVNumber());
}
}
......
#ifndef __GPSWIDGET_H__
#define __GPSWIDGET_H__
#include <QWidget>
#include "nmea.h"
namespace Ui {
class GPSWidget;
}
class GPSWidget: public QWidget
{
Q_OBJECT
public:
explicit GPSWidget(QWidget* parent =0);
~GPSWidget();
public slots:
void displayNMEAFrame(NMEAFrame f);
private:
Ui::GPSWidget* ui;
};
#endif //__GPSWIDGET_H__
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>GPSWidget</class>
<widget class="QWidget">
<property name="name">
<cstring>GPSWidget</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>203</width>
<height>140</height>
</rect>
</property>
<property name="caption">
<string>GPS Values</string>
</property>
<widget class="QLabel">
<property name="name">
<cstring>label2</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>70</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Latitude :</string>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>label1</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>70</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Longitude :</string>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>label4</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>70</y>
<width>70</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>DOP :</string>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>latitude</cstring>
</property>
<property name="geometry">
<rect>
<x>80</x>
<y>10</y>
<width>111</width>
<height>20</height>
</rect>
</property>
<property name="frameShape">
<enum>Box</enum>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>longitude</cstring>
</property>
<property name="geometry">
<rect>
<x>80</x>
<y>40</y>
<width>111</width>
<height>20</height>
</rect>
</property>
<property name="frameShape">
<enum>Box</enum>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>dop</cstring>
</property>
<property name="geometry">
<rect>
<x>80</x>
<y>70</y>
<width>111</width>
<height>20</height>
</rect>
</property>
<property name="frameShape">
<enum>Box</enum>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
<widget class="QLCDNumber">
<property name="name">
<cstring>sv</cstring>
</property>
<property name="geometry">
<rect>
<x>120</x>
<y>100</y>
<width>70</width>
<height>30</height>
</rect>
</property>
<property name="numDigits">
<number>2</number>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>label3</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>100</y>
<width>110</width>
<height>30</height>
</rect>
</property>
<property name="text">
<string>Satellites in view :</string>
</property>
</widget>
</widget>
<includes>
<include location="local" impldecl="in declaration">nmea.h</include>
<include location="local" impldecl="in implementation">gpswidget.ui.h</include>
</includes>
<slots>
<slot specifier="non virtual">displayNMEAFrame( NMEAFrame f )</slot>
</slots>
<layoutdefaults spacing="6" margin="11"/>
</UI>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GPSWidget</class>
<widget class="QWidget" name="GPSWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>203</width>
<height>140</height>
</rect>
</property>
<property name="windowTitle">
<string>GPS Values</string>
</property>
<widget class="QLabel" name="label2">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>70</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Latitude :</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
<widget class="QLabel" name="label1">
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>70</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Longitude :</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
<widget class="QLabel" name="label4">
<property name="geometry">
<rect>
<x>10</x>
<y>70</y>
<width>70</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>DOP :</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
<widget class="QLabel" name="latitude">
<property name="geometry">
<rect>
<x>80</x>
<y>10</y>
<width>111</width>
<height>20</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="text">
<string>-</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
<widget class="QLabel" name="longitude">
<property name="geometry">
<rect>
<x>80</x>
<y>40</y>
<width>111</width>
<height>20</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="text">
<string>-</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
<widget class="QLabel" name="dop">
<property name="geometry">
<rect>
<x>80</x>
<y>70</y>
<width>111</width>
<height>20</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="text">
<string>-</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
<widget class="QLCDNumber" name="sv">
<property name="geometry">
<rect>
<x>120</x>
<y>100</y>
<width>70</width>
<height>30</height>
</rect>
</property>
<property name="numDigits">
<number>2</number>
</property>
</widget>
<widget class="QLabel" name="label3">
<property name="geometry">
<rect>
<x>10</x>
<y>100</y>
<width>110</width>
<height>30</height>
</rect>
</property>
<property name="text">
<string>Satellites in view :</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<includes>
<include location="local">nmea.h</include>
</includes>
<resources/>
<connections/>
</ui>
......
#ifndef __GPSWWIDGET_H__
#define __GPSWWIDGET_H__
#include "ui/gpswidget.h"
//#include "ui/gpswidget.h"
#include "gpswidget.h"
/*! \brief This is an ARCS wrapper for the GPSWidget control panel.
* \author Jean-Yves Didier
......@@ -15,7 +17,7 @@ Q_OBJECT
/*! ARCS Constructor
*/
GPSWWidget(QObject* parent=0)
: GPSWidget(dynamic_cast<QWidget*>(parent)) {}
: GPSWidget() {}
};
......
<library>
<headers>
<header name="gpswwidget.h"/>
<header name="gpstracker.h"/>
<header name="gpstranslator.h"/>
<header name="gpslog.h"/>
<header name="gpstoogr.h"/>
<header name="triggps.h"/>
<header name="synsensor.h"/>
<header name="synchro.h"/>
</headers>
<components>
<component name="GPSTracker"/>
<component name="GPSWWidget"/>
<component name="GPSTranslator"/>
<component name="GPSLogger"/>
<component name="LoadGps"/>
<component name="GpsToOgr"/>
<component name="SetAltitude"/>
<component name="SynSensor"/>
<component name="GpsTrigger"/>
<component name="Synchronisation"/>
</components>
</library>
......@@ -7,11 +7,11 @@ bool NMEAFrame::isChecksumValid(QString s)
unsigned char checksum = 0;
int i=0;
if (s[0].latin1() != '$')
if (s[0].toAscii() != '$')
return false;
for ( i=1; i < s.length() && s[i].latin1() != '*'; i++ )
checksum ^= (unsigned char)s[i].latin1();
for ( i=1; i < s.length() && s[i].toAscii() != '*'; i++ )
checksum ^= (unsigned char)s[i].toAscii();
i++;
if (s.length() < i + 2)
......@@ -101,7 +101,7 @@ NMEAAngle NMEAFrame::parseAngle(QString s, QString t, int n)
// res.degrees = -res.degrees ;
// res.minutes = -res.minutes ;
// }
res.direction = t[0].latin1();
res.direction = t[0].toAscii();
res.valid = true;
......@@ -114,7 +114,7 @@ NMEAAngle NMEAFrame::parseAngle(QString s, QString t, int n)
void NMEAFrameGGA::parseFrame()
{
QStringList ls = QStringList::split(',',getRawFrame(),true);
QStringList ls = getRawFrame().split(",");
if (ls.count() != 15)
{
valid = false;
......@@ -157,7 +157,7 @@ void NMEAFrameGGA::dump()
void NMEAFrameGLL::parseFrame()
{
QStringList ls = QStringList::split(',',getRawFrame(),true);
QStringList ls = getRawFrame().split(',');
if (ls.count() != 8)
{
valid = false;
......@@ -195,7 +195,7 @@ void NMEAFrameGLL::dump()
void NMEAFrameRMC::parseFrame()
{
QStringList ls = QStringList::split(',',getRawFrame(),true);
QStringList ls = getRawFrame().split(',');
if (ls.count() != 13)
{
valid = false;
......@@ -210,7 +210,7 @@ void NMEAFrameRMC::parseFrame()
trackAngle = ls[8].toFloat();
UTDate = ls[9].toInt();
MAGVariation = ls[10].toFloat();
MAGDir = (ls[11])[0].latin1();
MAGDir = (ls[11])[0].toAscii();
valid = latitude.valid && longitude.valid && time.valid ;
......@@ -240,7 +240,7 @@ void NMEAFrameRMC::dump()
void NMEAFrameVTG::parseFrame()
{
QStringList ls = QStringList::split(',',getRawFrame(),true);
QStringList ls = getRawFrame().split(',');
if (ls.count() != 9)
{
return ;
......