1 |
|
---|
2 | #include <QThread>
|
---|
3 | #include <QSemaphore>
|
---|
4 | #include <QApplication>
|
---|
5 |
|
---|
6 | #include "kernel/ComponentBase.h"
|
---|
7 | #include "kernel/ComponentFactory.h"
|
---|
8 |
|
---|
9 | #ifdef WIN32
|
---|
10 | #include "../driver/win32SerialPort.h"
|
---|
11 | //#include "network/gpsServerSocket.h"
|
---|
12 | #else
|
---|
13 | #include "../driver/PosixSerialPort.h"
|
---|
14 | #endif
|
---|
15 |
|
---|
16 |
|
---|
17 | #include "structure/structureUBX.h"
|
---|
18 | #include "SerialCom/SerialCOM_Handle_Stream.hpp"
|
---|
19 | #include "SerialCom/Ublox/SerialCOM_Protocol_UBX.hpp"
|
---|
20 | #include "SerialCom/NMEA/SerialCOM_Protocol_NMEA.hpp"
|
---|
21 | #include "SerialCom/SerialCOM_Msg.hpp"
|
---|
22 | #include "SerialCom/Ublox/SerialCOM_Msg_RXM_RAW.hpp"
|
---|
23 | #include "SerialCom/Ublox/SerialCOM_Msg_RXM_SFRB.hpp"
|
---|
24 | #include "SerialCom/Ublox/SerialCOM_Msg_NAV_CLOCK.hpp"
|
---|
25 | #include "SerialCom/Ublox/SerialCOM_Msg_NAV_POSLLH.hpp"
|
---|
26 | #include "SerialCom/Ublox/SerialCOM_Msg_NAV_POSUTM.hpp"
|
---|
27 | #include "SerialCom/Ublox/SerialCOM_Msg_NAV_SOL.hpp"
|
---|
28 | #include "SerialCom/Ublox/SerialCOM_Msg_NAV_VELNED.hpp"
|
---|
29 | #include "SerialCom/Ublox/SerialCOM_Msg_NAV_SBAS.hpp"
|
---|
30 | #include "SerialCom/Ublox/SerialCOM_Msg_NAV_SVINFO.hpp"
|
---|
31 |
|
---|
32 |
|
---|
33 | /*! \class ubloxComponent
|
---|
34 | * \brief DByte component used to record ublox messages
|
---|
35 | * \author Olivier LE MARCHAND
|
---|
36 | * \version 1.0
|
---|
37 | * \date august 2009
|
---|
38 | * \bug Problem with the serial communication
|
---|
39 | * \warning None
|
---|
40 | *
|
---|
41 | * This class follows the DByte sensor architecture and acquire data from
|
---|
42 | * the ublox receiver with a serial communication port. Hence messages are
|
---|
43 | * decoded with the help of the SerialCOM librairy where Ublox protocol and
|
---|
44 | * Messages are implemeted.
|
---|
45 | *
|
---|
46 | */
|
---|
47 |
|
---|
48 | class ubloxComponent : public QThread, public ComponentBase
|
---|
49 | {
|
---|
50 | Q_OBJECT
|
---|
51 |
|
---|
52 | public:
|
---|
53 | /*! \brief Constructor. Create and configure objects from the SerialCOM librairy, and
|
---|
54 | * intialize member variables*/
|
---|
55 | ubloxComponent(QString name);
|
---|
56 |
|
---|
57 | /*! \brief Detructor. Free the memory of the objects from the SerialCOM library*/
|
---|
58 | ~ubloxComponent();
|
---|
59 |
|
---|
60 | /*! \brief Virtual function herited from ComponentBase. Start the thread and create
|
---|
61 | * and configure the serial port*/
|
---|
62 | void startActivity();
|
---|
63 |
|
---|
64 | /*! \brief Virtual function herited from ComponentBase. Stop the thread and destroy
|
---|
65 | * the serial port*/
|
---|
66 | void stopActivity();
|
---|
67 |
|
---|
68 | /*! \brief Virtual function herited from ComponentBase. Configure part of the serial port
|
---|
69 | * with data contained in the xml configuration file*/
|
---|
70 | ComponentBase::COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
|
---|
71 |
|
---|
72 |
|
---|
73 | /*! \brief Virtual function herited from ComponentBase. Main loop of the thread*/
|
---|
74 | /*! Receive data from the serial port, transmit it to the SerialCOM_Handle_Stream
|
---|
75 | * and record the data once a full message has been identified*/
|
---|
76 | void run();
|
---|
77 |
|
---|
78 | /*! Serial Port object*/
|
---|
79 | #ifdef WIN32
|
---|
80 | Win32SerialPort* serialPort;
|
---|
81 | #else
|
---|
82 | PosixSerialPort *serialPort;
|
---|
83 | #endif
|
---|
84 |
|
---|
85 | public slots:
|
---|
86 | /*! \brief to unlock the processing thread */
|
---|
87 | void unlockProcessing(int v);
|
---|
88 |
|
---|
89 | protected:
|
---|
90 | /*! \brief data frame currently read from the serial com port */
|
---|
91 | std::string currentDataFrame;
|
---|
92 |
|
---|
93 | /*! \brief time of arrival of the current data frame at the serial port */
|
---|
94 | road_time_t currentRoadtime;
|
---|
95 |
|
---|
96 | /*! \brief time uncertainty on the currentRoadtime */
|
---|
97 | road_timerange_t currentTimerange;
|
---|
98 |
|
---|
99 |
|
---|
100 | /*!\brief Object used to bufferize data and extract messages with the help of registered protocolhandle messages*/
|
---|
101 | SerialCOM_Handle_Stream *pHandleStream;
|
---|
102 |
|
---|
103 | /*! Object to handle ublox protocol */
|
---|
104 | Ublox::SerialCOM_Protocol_UBX *pProtocolUBX;
|
---|
105 |
|
---|
106 | /*! Object to handle NMEA protocol */
|
---|
107 | NMEA::SerialCOM_Protocol_NMEA *pProtocolNMEA;
|
---|
108 |
|
---|
109 | QSemaphore semaphore;
|
---|
110 |
|
---|
111 | /*!\brief Name of the serial port*/
|
---|
112 | QString portName;
|
---|
113 |
|
---|
114 | };
|
---|
115 |
|
---|