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

Last change on this file since 621 was 621, checked in by mervart, 16 years ago

* empty log message *

File size: 4.0 KB
Line 
1// Part of BNC, a utility for retrieving decoding and
2// converting GNSS data streams from NTRIP broadcasters.
3//
4// Copyright (C) 2007
5// German Federal Agency for Cartography and Geodesy (BKG)
6// http://www.bkg.bund.de
7// Czech Technical University Prague, Department of Geodesy
8// http://www.fsv.cvut.cz
9//
10// Email: euref-ip@bkg.bund.de
11//
12// This program is free software; you can redistribute it and/or
13// modify it under the terms of the GNU General Public License
14// as published by the Free Software Foundation, version 2.
15//
16// This program is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this program; if not, write to the Free Software
23// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
25/* -------------------------------------------------------------------------
26 * BKG NTRIP Client
27 * -------------------------------------------------------------------------
28 *
29 * Class: RTIGSDecoder
30 *
31 * Purpose: RTIGS Decoder
32 *
33 * Author: L. Mervart
34 *
35 * Created: 24-Aug-2006
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include "RTIGSDecoder.h"
42#include "bncconst.h"
43
44using namespace std;
45
46#undef L1
47#undef L2
48
49// Constructor
50////////////////////////////////////////////////////////////////////////////
51RTIGSDecoder::RTIGSDecoder() {
52}
53
54// Destructor
55////////////////////////////////////////////////////////////////////////////
56RTIGSDecoder::~RTIGSDecoder() {
57 QListIterator<p_obs> it(_obsList);
58 while (it.hasNext()) {
59 delete it.next();
60 }
61 _obsList.clear();
62}
63
64//
65////////////////////////////////////////////////////////////////////////////
66void RTIGSDecoder::Decode(char* buffer, int bufLen) {
67
68 // Append the incomming data to the internal buffer
69 // ------------------------------------------------
70 _buffer.append(buffer, bufLen);
71
72 // Find the beginning of the message
73 // ---------------------------------
74 bool found = false;
75 for (unsigned ii = 0; ii < _buffer.size(); ii++) {
76 unsigned short xx;
77 memcpy( (void*) &xx, &_buffer[ii], sizeof(xx) );
78 if (_GPSTrans.f_IsLittleEndian) {
79 SwitchBytes( (char*) &xx, sizeof(xx) );
80 }
81 if (xx == 200) {
82 _buffer = _buffer.substr(ii);
83 found = true;
84 break;
85 }
86 }
87
88 if (! found) {
89 _buffer.clear();
90 return;
91 }
92
93 unsigned char* p_buf = (unsigned char*) _buffer.data();
94
95 unsigned short messType = _GPSTrans.GetRTIGSHdrRecType(p_buf);
96 unsigned short numbytes = _GPSTrans.GetRTIGSHdrRecBytes(p_buf);
97
98 // Not enough new data, return
99 // ---------------------------
100 if (_buffer.size() < numbytes) {
101 return;
102 }
103
104 // Decode the epoch
105 // ----------------
106 if (messType == 200) {
107 RTIGSO_T rtigs_obs;
108 short numObs = _GPSTrans.Decode_RTIGS_Obs(p_buf, numbytes, rtigs_obs);
109
110 for (short ii = 0; ii < numObs; ii++) {
111 Observation* obs = new Observation();
112 obs->satSys = 'G';
113 obs->satNum = _GPSTrans.DecObs.Obs[ii].sat_prn;
114 obs->GPSWeek = _GPSTrans.DecObs.Obs[ii].GPSTime / (7 * 86400);
115 obs->GPSWeeks = _GPSTrans.DecObs.Obs[ii].GPSTime % (7 * 86400);
116 obs->C1 = _GPSTrans.DecObs.Obs[ii].l1_pseudo_range;
117 obs->P1 = _GPSTrans.DecObs.Obs[ii].p1_pseudo_range;
118 obs->P2 = _GPSTrans.DecObs.Obs[ii].p2_pseudo_range;
119 obs->L1 = _GPSTrans.DecObs.Obs[ii].p1_phase;
120 obs->L2 = _GPSTrans.DecObs.Obs[ii].p2_phase;
121 obs->S1 = _GPSTrans.DecObs.Obs[ii].l1_sn;
122 obs->S2 = _GPSTrans.DecObs.Obs[ii].l2_sn;
123 obs->SNR1 = int(ceil(_GPSTrans.DecObs.Obs[ii].l1_sn / 60.0 * 9.0));
124 obs->SNR2 = int(ceil(_GPSTrans.DecObs.Obs[ii].l2_sn / 60.0 * 9.0));
125
126 _obsList.push_back(obs);
127 }
128 }
129
130 // Unprocessed bytes remain in buffer
131 // ----------------------------------
132 _buffer = _buffer.substr(numbytes);
133}
Note: See TracBrowser for help on using the repository browser.