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

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

* empty log message *

File size: 4.0 KB
RevLine 
[306]1// Part of BNC, a utility for retrieving decoding and
[464]2// converting GNSS data streams from NTRIP broadcasters.
[306]3//
[464]4// Copyright (C) 2007
[306]5// German Federal Agency for Cartography and Geodesy (BKG)
6// http://www.bkg.bund.de
[464]7// Czech Technical University Prague, Department of Geodesy
[306]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.
[293]24
25/* -------------------------------------------------------------------------
26 * BKG NTRIP Client
27 * -------------------------------------------------------------------------
28 *
[306]29 * Class: RTIGSDecoder
[293]30 *
31 * Purpose: RTIGS Decoder
32 *
33 * Author: L. Mervart
34 *
35 * Created: 24-Aug-2006
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
[306]41#include "RTIGSDecoder.h"
[293]42#include "bncconst.h"
43
44using namespace std;
45
[305]46#undef L1
47#undef L2
48
[293]49// Constructor
50////////////////////////////////////////////////////////////////////////////
[306]51RTIGSDecoder::RTIGSDecoder() {
[293]52}
53
54// Destructor
55////////////////////////////////////////////////////////////////////////////
[306]56RTIGSDecoder::~RTIGSDecoder() {
[293]57}
58
59//
60////////////////////////////////////////////////////////////////////////////
[649]61t_irc RTIGSDecoder::Decode(char* buffer, int bufLen) {
[293]62
63 // Append the incomming data to the internal buffer
64 // ------------------------------------------------
[457]65 _buffer.append(buffer, bufLen);
[293]66
67 // Find the beginning of the message
68 // ---------------------------------
69 bool found = false;
[457]70 for (unsigned ii = 0; ii < _buffer.size(); ii++) {
[293]71 unsigned short xx;
[457]72 memcpy( (void*) &xx, &_buffer[ii], sizeof(xx) );
[305]73 if (_GPSTrans.f_IsLittleEndian) {
74 SwitchBytes( (char*) &xx, sizeof(xx) );
75 }
[293]76 if (xx == 200) {
[457]77 _buffer = _buffer.substr(ii);
[293]78 found = true;
79 break;
80 }
81 }
[305]82
[293]83 if (! found) {
84 _buffer.clear();
[649]85 return failure;
[293]86 }
87
[305]88 unsigned char* p_buf = (unsigned char*) _buffer.data();
[293]89
[305]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) {
[652]96 return success;
[293]97 }
98
[305]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);
[293]104
[305]105 for (short ii = 0; ii < numObs; ii++) {
[622]106 p_obs obs = new t_obs();
[627]107 _obsList.push_back(obs);
[622]108 obs->_o.satSys = 'G';
109 obs->_o.satNum = _GPSTrans.DecObs.Obs[ii].sat_prn;
110 obs->_o.GPSWeek = _GPSTrans.DecObs.Obs[ii].GPSTime / (7 * 86400);
111 obs->_o.GPSWeeks = _GPSTrans.DecObs.Obs[ii].GPSTime % (7 * 86400);
112 obs->_o.C1 = _GPSTrans.DecObs.Obs[ii].l1_pseudo_range;
113 obs->_o.P1 = _GPSTrans.DecObs.Obs[ii].p1_pseudo_range;
114 obs->_o.P2 = _GPSTrans.DecObs.Obs[ii].p2_pseudo_range;
115 obs->_o.L1 = _GPSTrans.DecObs.Obs[ii].p1_phase;
116 obs->_o.L2 = _GPSTrans.DecObs.Obs[ii].p2_phase;
117 obs->_o.S1 = _GPSTrans.DecObs.Obs[ii].l1_sn;
118 obs->_o.S2 = _GPSTrans.DecObs.Obs[ii].l2_sn;
119 obs->_o.SNR1 = int(ceil(_GPSTrans.DecObs.Obs[ii].l1_sn / 60.0 * 9.0));
120 obs->_o.SNR2 = int(ceil(_GPSTrans.DecObs.Obs[ii].l2_sn / 60.0 * 9.0));
[293]121 }
122 }
123
124 // Unprocessed bytes remain in buffer
125 // ----------------------------------
[457]126 _buffer = _buffer.substr(numbytes);
[649]127
128 return success;
[293]129}
Note: See TracBrowser for help on using the repository browser.