[59] | 1 | /*********************************************************************
|
---|
| 2 | // created: 2011/06/28 - 18:18
|
---|
| 3 | // filename: cptComponent.h
|
---|
| 4 | //
|
---|
| 5 | // author: Sergio Rodriguez
|
---|
| 6 | //
|
---|
| 7 | // version: $Id: $
|
---|
| 8 | //
|
---|
| 9 | // purpose: Acquire SPAN CPT data
|
---|
| 10 | //
|
---|
| 11 | *********************************************************************/
|
---|
| 12 |
|
---|
| 13 | #ifndef CPTCOMPONENT_H
|
---|
| 14 | #define CPTCOMPONENT_H
|
---|
| 15 |
|
---|
| 16 | #include <fstream>
|
---|
| 17 | #include <qobject.h>
|
---|
| 18 | #include <string>
|
---|
| 19 |
|
---|
| 20 | #include "../NMEA0183/include/nmea0183.h"
|
---|
| 21 | #include "Pacpus/kernel/ComponentBase.h"
|
---|
| 22 | #include "Pacpus/kernel/DbiteFile.h"
|
---|
| 23 | #include "Pacpus/kernel/pacpus.h"
|
---|
| 24 | #include "../Gps/structure_gps.h"
|
---|
| 25 |
|
---|
| 26 | #ifdef WIN32
|
---|
| 27 | # include "../driver/win32SerialPort.h"
|
---|
| 28 | #else
|
---|
| 29 | # include "../driver/PosixSerialPort.h"
|
---|
| 30 | #endif
|
---|
| 31 |
|
---|
| 32 | // Export macro for CPTComponent DLL for Windows only
|
---|
| 33 | #ifdef WIN32
|
---|
| 34 | # ifdef CPTCOMPONENT_EXPORTS
|
---|
| 35 | // make DLL
|
---|
| 36 | # define CPTCOMPONENT_API __declspec(dllexport)
|
---|
| 37 | # else
|
---|
| 38 | // use DLL
|
---|
| 39 | # define CPTCOMPONENT_API __declspec(dllimport)
|
---|
| 40 | # endif
|
---|
| 41 | #else
|
---|
| 42 | // On other platforms, simply ignore this
|
---|
| 43 | # define CPTCOMPONENT_API
|
---|
| 44 | #endif
|
---|
| 45 |
|
---|
| 46 | namespace pacpus {
|
---|
| 47 |
|
---|
| 48 | class ShMem;
|
---|
| 49 |
|
---|
| 50 | struct CPTCOMPONENT_API Stream8Position
|
---|
| 51 | {
|
---|
| 52 | int32_t dataPos;
|
---|
| 53 | int32_t length;
|
---|
| 54 | };
|
---|
| 55 |
|
---|
| 56 | #define UNKNOWN_NMEA_FRAME -1
|
---|
| 57 |
|
---|
| 58 | /// The definition of the CPTComponent class
|
---|
| 59 | class CPTCOMPONENT_API CPTComponent
|
---|
| 60 | : public QObject
|
---|
| 61 | , public ComponentBase
|
---|
| 62 | {
|
---|
| 63 | Q_OBJECT
|
---|
| 64 |
|
---|
| 65 | public:
|
---|
| 66 | CPTComponent(QString name);
|
---|
| 67 | ~CPTComponent();
|
---|
| 68 |
|
---|
| 69 | virtual void stopActivity(); /*!< to stop the processing thread */
|
---|
| 70 | virtual void startActivity(); /*!< to start the processing thread */
|
---|
| 71 | virtual ComponentBase::COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
|
---|
| 72 |
|
---|
| 73 | void setPortCOM(const char * port);
|
---|
| 74 |
|
---|
| 75 | public slots:
|
---|
| 76 | void processing(int v); /*!< to unlock the processing thread */
|
---|
| 77 |
|
---|
| 78 | private:
|
---|
| 79 | char * mAllFramesBuffer;
|
---|
| 80 | #ifdef WIN32
|
---|
| 81 | Win32SerialPort * serialPort;
|
---|
| 82 | #else
|
---|
| 83 | PosixSerialPort * serialPort;
|
---|
| 84 | #endif
|
---|
| 85 |
|
---|
| 86 | road_time_t currentRoadtime_;
|
---|
| 87 | road_timerange_t currentTimerange_;
|
---|
| 88 | int currentDataFrameLength_;
|
---|
| 89 |
|
---|
| 90 | bool mVerbose;
|
---|
| 91 | bool enuRef_;
|
---|
| 92 | double LAT_REF;
|
---|
| 93 | double LON_REF;
|
---|
| 94 | double HE_REF;
|
---|
| 95 |
|
---|
| 96 | QString portName;
|
---|
| 97 |
|
---|
| 98 | //ShMems
|
---|
| 99 | ShMem * mShMem;
|
---|
| 100 |
|
---|
| 101 | //Dbt files
|
---|
| 102 | pacpus::DbiteFile raws8hdFile;
|
---|
| 103 | std::ofstream dataFile_;
|
---|
| 104 |
|
---|
| 105 | pacpus::DbiteFile bestgpsposaFile_;
|
---|
| 106 | pacpus::DbiteFile rawimuFile_;
|
---|
| 107 | pacpus::DbiteFile inspvaFile_;
|
---|
| 108 | pacpus::DbiteFile inscovFile_;
|
---|
| 109 |
|
---|
| 110 | Stream8Position s8Data_;
|
---|
| 111 |
|
---|
| 112 | //Decoding
|
---|
| 113 | QString currentDataFrame;
|
---|
| 114 | road_time_t currentRoadtime;
|
---|
| 115 | road_timerange_t currentTimerange;
|
---|
| 116 |
|
---|
| 117 | QString frameToDecode;
|
---|
| 118 | road_time_t timeOfFrameToDecode;
|
---|
| 119 | road_timerange_t timerangeOfFrameToDecode;
|
---|
| 120 |
|
---|
| 121 | QString restOfFrame;
|
---|
| 122 |
|
---|
| 123 | bool newFrameToDecode;
|
---|
| 124 | bool startOfFrame;
|
---|
| 125 | int sofIdx_;
|
---|
| 126 | bool endOfFrame;
|
---|
| 127 | int type;
|
---|
| 128 | int eofIdx_;
|
---|
| 129 |
|
---|
| 130 | NMEA0183 nmea0183_;
|
---|
| 131 |
|
---|
| 132 | trame_gga_dbl ggaFrame_;
|
---|
| 133 | trame_gsa gsaFrame_;
|
---|
| 134 | trame_gst gstFrame_;
|
---|
| 135 | trame_gsv gsvFrame_;
|
---|
| 136 | trame_hdt hdtFrame_;
|
---|
| 137 | trame_rmc rmcFrame_;
|
---|
| 138 | trame_rot rotFrame_;
|
---|
| 139 | trame_vtg vtgFrame_;
|
---|
| 140 | trame_zda zdaFrame_;
|
---|
| 141 |
|
---|
| 142 | trame_bestgpsposa bestgpsposaFrame_;
|
---|
| 143 | trame_rawimusa rawimuFrame_;
|
---|
| 144 | trame_inspvaa inspvaFrame_;
|
---|
| 145 | trame_inscov inscovFrame_;
|
---|
| 146 |
|
---|
| 147 | int analyzeFrame(void);
|
---|
| 148 | int frameType(const QString);
|
---|
| 149 | int decodeFrame(int);
|
---|
| 150 |
|
---|
| 151 | int parseCPTbestgpsposa(QString);
|
---|
| 152 | int parseCPTrawimusa(QString);
|
---|
| 153 | int parseCPTinspvaa(QString);
|
---|
| 154 | int parseCPTinscov(QString);
|
---|
| 155 |
|
---|
| 156 | void initBuffer( TimestampedBestgpsposaFrame*,
|
---|
| 157 | TimestampedRawimusaFrame*,
|
---|
| 158 | TimestampedInspvaaFrame*,
|
---|
| 159 | TimestampedInscovFrame*);
|
---|
| 160 | };
|
---|
| 161 |
|
---|
| 162 | } // namespace pacpus
|
---|
| 163 |
|
---|
| 164 | #endif // CPTCOMPONENT_H
|
---|