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

Last change on this file since 558 was 464, checked in by weber, 17 years ago

* empty log message *

File size: 3.9 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}
58
59//
60////////////////////////////////////////////////////////////////////////////
61void RTIGSDecoder::Decode(char* buffer, int bufLen) {
62
63 // Append the incomming data to the internal buffer
64 // ------------------------------------------------
65 _buffer.append(buffer, bufLen);
66
67 // Find the beginning of the message
68 // ---------------------------------
69 bool found = false;
70 for (unsigned ii = 0; ii < _buffer.size(); ii++) {
71 unsigned short xx;
72 memcpy( (void*) &xx, &_buffer[ii], sizeof(xx) );
73 if (_GPSTrans.f_IsLittleEndian) {
74 SwitchBytes( (char*) &xx, sizeof(xx) );
75 }
76 if (xx == 200) {
77 _buffer = _buffer.substr(ii);
78 found = true;
79 break;
80 }
81 }
82
83 if (! found) {
84 _buffer.clear();
85 return;
86 }
87
88 unsigned char* p_buf = (unsigned char*) _buffer.data();
89
90 unsigned short messType = _GPSTrans.GetRTIGSHdrRecType(p_buf);
91 unsigned short numbytes = _GPSTrans.GetRTIGSHdrRecBytes(p_buf);
92
93 // Not enough new data, return
94 // ---------------------------
95 if (_buffer.size() < numbytes) {
96 return;
97 }
98
99 // Decode the epoch
100 // ----------------
101 if (messType == 200) {
102 RTIGSO_T rtigs_obs;
103 short numObs = _GPSTrans.Decode_RTIGS_Obs(p_buf, numbytes, rtigs_obs);
104
105 for (short ii = 0; ii < numObs; ii++) {
106 Observation* obs = new Observation();
107 obs->satSys = 'G';
108 obs->satNum = _GPSTrans.DecObs.Obs[ii].sat_prn;
109 obs->GPSWeek = _GPSTrans.DecObs.Obs[ii].GPSTime / (7 * 86400);
110 obs->GPSWeeks = _GPSTrans.DecObs.Obs[ii].GPSTime % (7 * 86400);
111 obs->C1 = _GPSTrans.DecObs.Obs[ii].l1_pseudo_range;
112 obs->P1 = _GPSTrans.DecObs.Obs[ii].p1_pseudo_range;
113 obs->P2 = _GPSTrans.DecObs.Obs[ii].p2_pseudo_range;
114 obs->L1 = _GPSTrans.DecObs.Obs[ii].p1_phase;
115 obs->L2 = _GPSTrans.DecObs.Obs[ii].p2_phase;
116 obs->S1 = _GPSTrans.DecObs.Obs[ii].l1_sn;
117 obs->S2 = _GPSTrans.DecObs.Obs[ii].l2_sn;
118 obs->SNR1 = int(ceil(_GPSTrans.DecObs.Obs[ii].l1_sn / 60.0 * 9.0));
119 obs->SNR2 = int(ceil(_GPSTrans.DecObs.Obs[ii].l2_sn / 60.0 * 9.0));
120
121 _obsList.push_back(obs);
122 }
123 }
124
125 // Unprocessed bytes remain in buffer
126 // ----------------------------------
127 _buffer = _buffer.substr(numbytes);
128}
Note: See TracBrowser for help on using the repository browser.