1 |
|
---|
2 | /* -------------------------------------------------------------------------
|
---|
3 | * BKG NTRIP Client
|
---|
4 | * -------------------------------------------------------------------------
|
---|
5 | *
|
---|
6 | * Class: rtigs
|
---|
7 | *
|
---|
8 | * Purpose: RTIGS Decoder
|
---|
9 | *
|
---|
10 | * Author: L. Mervart
|
---|
11 | *
|
---|
12 | * Created: 24-Aug-2006
|
---|
13 | *
|
---|
14 | * Changes:
|
---|
15 | *
|
---|
16 | * -----------------------------------------------------------------------*/
|
---|
17 |
|
---|
18 | #include "rtigs.h"
|
---|
19 |
|
---|
20 | using namespace std;
|
---|
21 |
|
---|
22 | #undef L1
|
---|
23 | #undef L2
|
---|
24 |
|
---|
25 | // Constructor
|
---|
26 | ////////////////////////////////////////////////////////////////////////////
|
---|
27 | rtigs::rtigs() : GPSDecoder() {
|
---|
28 | }
|
---|
29 |
|
---|
30 | // Destructor
|
---|
31 | ////////////////////////////////////////////////////////////////////////////
|
---|
32 | rtigs::~rtigs() {
|
---|
33 | }
|
---|
34 |
|
---|
35 | //
|
---|
36 | ////////////////////////////////////////////////////////////////////////////
|
---|
37 | void rtigs::Decode(char* buffer, int bufLen) {
|
---|
38 |
|
---|
39 | // Append the incomming data to the internal buffer
|
---|
40 | // ------------------------------------------------
|
---|
41 | _buffer.append( QByteArray(buffer, bufLen) );
|
---|
42 |
|
---|
43 | // Find the beginning of the message
|
---|
44 | // ---------------------------------
|
---|
45 | bool found = false;
|
---|
46 | for (int ii = 0; ii < _buffer.size(); ii++) {
|
---|
47 | unsigned short xx;
|
---|
48 | memcpy( (void*) &xx, &_buffer.data()[ii], sizeof(xx) );
|
---|
49 | if (_GPSTrans.f_IsLittleEndian) {
|
---|
50 | SwitchBytes( (char*) &xx, sizeof(xx) );
|
---|
51 | }
|
---|
52 | if (xx == 200) {
|
---|
53 | _buffer = _buffer.mid(ii);
|
---|
54 | found = true;
|
---|
55 | break;
|
---|
56 | }
|
---|
57 | }
|
---|
58 |
|
---|
59 | if (! found) {
|
---|
60 | _buffer.clear();
|
---|
61 | return;
|
---|
62 | }
|
---|
63 |
|
---|
64 | unsigned char* p_buf = (unsigned char*) _buffer.data();
|
---|
65 |
|
---|
66 | unsigned short messType = _GPSTrans.GetRTIGSHdrRecType(p_buf);
|
---|
67 | unsigned short numbytes = _GPSTrans.GetRTIGSHdrRecBytes(p_buf);
|
---|
68 |
|
---|
69 | // Not enough new data, return
|
---|
70 | // ---------------------------
|
---|
71 | if (_buffer.size() < numbytes) {
|
---|
72 | return;
|
---|
73 | }
|
---|
74 |
|
---|
75 | // Decode the epoch
|
---|
76 | // ----------------
|
---|
77 | if (messType == 200) {
|
---|
78 | RTIGSO_T rtigs_obs;
|
---|
79 | short numObs = _GPSTrans.Decode_RTIGS_Obs(p_buf, numbytes, rtigs_obs);
|
---|
80 |
|
---|
81 | for (short ii = 0; ii < numObs; ii++) {
|
---|
82 | Observation* obs = new Observation();
|
---|
83 |
|
---|
84 | obs->SVPRN = _GPSTrans.DecObs.Obs[ii].sat_prn;
|
---|
85 | obs->GPSWeek = _GPSTrans.DecObs.Obs[ii].GPSTime / (7 * 86400);
|
---|
86 | obs->GPSWeeks = _GPSTrans.DecObs.Obs[ii].GPSTime % (7 * 86400);
|
---|
87 | obs->sec = _GPSTrans.DecObs.Obs[ii].GPSTime % 3600;
|
---|
88 | obs->pCodeIndicator = 1;
|
---|
89 | obs->C1 = _GPSTrans.DecObs.Obs[ii].p1_pseudo_range;
|
---|
90 | obs->P2 = _GPSTrans.DecObs.Obs[ii].p2_pseudo_range;
|
---|
91 | obs->L1 = _GPSTrans.DecObs.Obs[ii].p1_phase * (C / F1); // ok
|
---|
92 | obs->L2 = _GPSTrans.DecObs.Obs[ii].l1_phase * (C / F1); // strange, probably bug in RTIGS converter
|
---|
93 | obs->SNR1 = (short) _GPSTrans.DecObs.Obs[ii].l1_sn * 10;
|
---|
94 | obs->SNR2 = (short) _GPSTrans.DecObs.Obs[ii].l2_sn * 10;
|
---|
95 | obs->cumuLossOfCont = 0;
|
---|
96 |
|
---|
97 | m_lObsList.push_back(obs);
|
---|
98 | }
|
---|
99 | }
|
---|
100 |
|
---|
101 | // Unprocessed bytes remain in buffer
|
---|
102 | // ----------------------------------
|
---|
103 | _buffer = _buffer.mid(numbytes);
|
---|
104 | }
|
---|