source: ntrip/trunk/BNC/RTIGS/RTIGSDecoder.cpp@ 305

Last change on this file since 305 was 305, checked in by mervart, 17 years ago

* empty log message *

File size: 2.8 KB
Line 
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#include "bncconst.h"
20
21using namespace std;
22
23#undef L1
24#undef L2
25
26// Constructor
27////////////////////////////////////////////////////////////////////////////
28rtigs::rtigs() {
29}
30
31// Destructor
32////////////////////////////////////////////////////////////////////////////
33rtigs::~rtigs() {
34}
35
36//
37////////////////////////////////////////////////////////////////////////////
38void rtigs::Decode(char* buffer, int bufLen) {
39
40 // Append the incomming data to the internal buffer
41 // ------------------------------------------------
42 _buffer.append( QByteArray(buffer, bufLen) );
43
44 // Find the beginning of the message
45 // ---------------------------------
46 bool found = false;
47 for (int ii = 0; ii < _buffer.size(); ii++) {
48 unsigned short xx;
49 memcpy( (void*) &xx, &_buffer.data()[ii], sizeof(xx) );
50 if (_GPSTrans.f_IsLittleEndian) {
51 SwitchBytes( (char*) &xx, sizeof(xx) );
52 }
53 if (xx == 200) {
54 _buffer = _buffer.mid(ii);
55 found = true;
56 break;
57 }
58 }
59
60 if (! found) {
61 _buffer.clear();
62 return;
63 }
64
65 unsigned char* p_buf = (unsigned char*) _buffer.data();
66
67 unsigned short messType = _GPSTrans.GetRTIGSHdrRecType(p_buf);
68 unsigned short numbytes = _GPSTrans.GetRTIGSHdrRecBytes(p_buf);
69
70 // Not enough new data, return
71 // ---------------------------
72 if (_buffer.size() < numbytes) {
73 return;
74 }
75
76 // Decode the epoch
77 // ----------------
78 if (messType == 200) {
79 RTIGSO_T rtigs_obs;
80 short numObs = _GPSTrans.Decode_RTIGS_Obs(p_buf, numbytes, rtigs_obs);
81
82 for (short ii = 0; ii < numObs; ii++) {
83 Observation* obs = new Observation();
84
85 obs->SVPRN = _GPSTrans.DecObs.Obs[ii].sat_prn;
86 obs->GPSWeek = _GPSTrans.DecObs.Obs[ii].GPSTime / (7 * 86400);
87 obs->GPSWeeks = _GPSTrans.DecObs.Obs[ii].GPSTime % (7 * 86400);
88 obs->C1 = _GPSTrans.DecObs.Obs[ii].l1_pseudo_range;
89 obs->P1 = _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;
92 obs->L2 = _GPSTrans.DecObs.Obs[ii].p2_phase;
93 obs->SNR1 = int(_GPSTrans.DecObs.Obs[ii].l1_sn * 10);
94 obs->SNR2 = int(_GPSTrans.DecObs.Obs[ii].l2_sn * 10);
95
96 _obsList.push_back(obs);
97 }
98 }
99
100 // Unprocessed bytes remain in buffer
101 // ----------------------------------
102 _buffer = _buffer.mid(numbytes);
103}
Note: See TracBrowser for help on using the repository browser.