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

Last change on this file since 87 was 59, checked in by DHERBOMEZ Gérald, 10 years ago

Integration of new modules:

  • GPS NMEA0183 decoder
  • Span CPT Decoder

Update of:

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