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

Last change on this file since 100 was 99, checked in by nguyenhu, 9 years ago

compilation under linux with 0.2.X framework

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