source: pacpussensors/trunk/Gps/gpsComponent.h@ 118

Last change on this file since 118 was 118, checked in by DHERBOMEZ Gérald, 8 years ago

add output for HDT, VTG, GGA frames
add timestamped structures for GPS

File size: 5.2 KB
Line 
1/// Purpose: This class decodes NMEA0183 data and can store them
2/// in dbt files. It implements a thread which gets frames
3/// from dataFrame class.
4///
5/// @date created 2005/09/02 - 8:06
6/// @author: Gerald Dherbomez
7/// @version: $Id: gpsComponent.h 1277 2013-01-10 16:49:06Z bonnetst $
8///
9/// @todo replace the static shared memory by the class ShMem
10
11#ifndef GPSCOMPONENT_H
12#define GPSCOMPONENT_H
13
14#include "Pacpus/kernel/pacpus.h"
15#include "Pacpus/kernel/ComponentBase.h"
16#include "Pacpus/kernel/DbiteFile.h"
17#include "../NMEA0183/include/nmea0183.h"
18#include <Pacpus/kernel/InputOutputInterface.h>
19
20#include "GpsFrames.h"
21
22#include <QSemaphore>
23#include <QThread>
24#include <QByteArray>
25#include <QString>
26
27#ifdef WIN32
28# include "../driver/win32SerialPort.h"
29//# include "network/gpsServerSocket.h"
30#else
31# include "../driver/PosixSerialPort.h"
32#endif
33//#include "DbitePlayer/SensorTcpServer.h"
34#include "Pacpus/PacpusTools/ShMem.h"
35
36// Export macro for PluginTest DLL for Windows only
37#ifdef WIN32
38# ifdef GPS_EXPORTS
39 // make DLL
40# define GPS_API __declspec(dllexport)
41# else
42 // use DLL
43# define GPS_API __declspec(dllimport)
44# endif
45#else
46 // On other platforms, simply ignore this
47# define GPS_API /* nothing */
48#endif
49
50class QFile;
51
52namespace pacpus {
53
54/*!
55* The definition of the GpsComponent class
56*/
57class GPS_API GpsComponent
58 : public QThread
59 , public ComponentBase
60 , public GpsFrames
61{
62 Q_OBJECT
63
64public:
65 GpsComponent(QString name);
66 ~GpsComponent();
67
68 virtual void stopActivity(); /*!< to stop the processing thread */
69 virtual void startActivity(); /*!< to start the processing thread */
70 virtual ComponentBase::COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
71
72
73 void enableSocketServer(int portNumber); /*!< to enable the socket server interface on port portNumber*/
74 void disableSocketServer(); /*!< to disable the socket server interface */
75
76 void setPortCOM(const char * port);
77
78
79
80public slots:
81 void unlockProcessing(int v); /*!< to unlock the processing thread */
82
83protected:
84private:
85 void run(); /*!< the main loop of the thread */
86 int frameType(const QByteArray& frame); /*!< to get the type of the frame */
87 int decodeFrame(int type); /*!< parse the string in the NMEA0183 class to get the frame informations */
88 bool currentFrameIsPps(); /*!< checks if a frame is an out-of-band pps signal */
89 bool analyzeFrame(); /*!< reconstruct the entire frame starting from the received pieces */
90
91 void addOutputs();
92
93#ifdef WIN32
94 Win32SerialPort * serialPort;
95 //GpsServerSocket * serverSocket;
96#else
97 PosixSerialPort * serialPort;
98#endif
99 // a pointer to the TCP server that send data on the network
100 //SensorTcpServer * tcpServer_;
101
102 static const int MAX_FRAMES = 9;
103
104 struct FrameTypeMap {
105 char *code;
106 int type;
107 };
108
109 static FrameTypeMap frameTypes[MAX_FRAMES];
110
111 NMEA0183 nmea0183_;
112 QSemaphore semaphore_;
113
114 FRAME* currentFrame_;
115
116 FRAME frameToDecode_;
117
118 road_time_t lastPpsTime_;
119
120 bool newFrameToDecode_;
121 bool startOfFrame_;
122 bool endOfFrame_;
123 int nextByteToProcess_;
124
125
126 unsigned int ppsIndex_;
127
128 DbiteFile ppshdFile; /*!< pointer to the pps dbt file */
129 DbiteFile ggahdFile; /*!< pointer to the gga dbt file */
130 DbiteFile gsahdFile; /*!< pointer to the gsa dbt file */
131 DbiteFile gsthdFile; /*!< pointer to the gst dbt file */
132 DbiteFile gsvhdFile; /*!< pointer to the gsv dbt file */
133 DbiteFile hdthdFile; /*!< pointer to the hdt dbt file */
134 DbiteFile rmchdFile; /*!< pointer to the rmc dbt file */
135 DbiteFile rothdFile; /*!< pointer to the rot dbt file */
136 DbiteFile vtghdFile; /*!< pointer to the vtg dbt file */
137 DbiteFile zdahdFile; /*!< pointer to the zda dbt file */
138
139 DbiteFile gpsSynchroFile; /*!< pointer to the zda dbt file */
140
141 QFile * file;
142
143 bool ppsRecording;
144 bool ggaRecording;
145 bool gsaRecording;
146 bool gstRecording;
147 bool gsvRecording;
148 bool hdtRecording;
149 bool rmcRecording;
150 bool rotRecording;
151 bool vtgRecording;
152 bool zdaRecording;
153
154 QString portName_;
155
156 ShMem * shMem_;
157
158 TimestampedGgaFrame mGga;
159 TimestampedVtgFrame mVtg;
160 TimestampedHdtFrame mHdt;
161
162 // Declaration of outputs
163 OutputInterface<TimestampedGgaFrame, GpsComponent>* outGga_;
164 OutputInterface<TimestampedVtgFrame, GpsComponent>* outVtg_;
165 OutputInterface<TimestampedHdtFrame, GpsComponent>* outHdt_;
166
167 /// For the socket server
168 /* Qt3 version - 17/12/2007
169 BOOL socketServerEnabled;
170 void *frameToSend;
171 QCustomEvent *evt;
172 */
173
174 /*
175 * VC6 doesn't support out-of-class template defintions
176 * see on http://support.microsoft.com kb q243451 and more particulary 241949
177 */
178 template<typename T>
179 void sendDataToServerSocket(T /*frame*/, int /*type*/)
180 {
181 /* Qt3 version - 17/12/2007
182 if (socketServerEnabled)
183 {
184 frameToSend = new T;
185 *(T*)frameToSend = frame;
186 evt = new QCustomEvent(QEvent::User + type);
187 evt->setData(frameToSend);
188 postEvent(serverSocket,evt);
189 }
190 */
191 }
192};
193
194} // namespace pacpus
195
196#endif // GPSCOMPONENT_H
Note: See TracBrowser for help on using the repository browser.