source: ntrip/trunk/BNC/RTCM3/RTCM3coDecoder.cpp@ 926

Last change on this file since 926 was 920, checked in by weber, 18 years ago

* empty log message *

File size: 4.6 KB
RevLine 
[866]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: RTCM3coDecoder
30 *
31 * Purpose: RTCM3 Clock Orbit Decoder
32 *
33 * Author: L. Mervart
34 *
35 * Created: 05-May-2008
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
[868]41#include <stdio.h>
[920]42#include <math.h>
[868]43
[866]44#include "RTCM3coDecoder.h"
[918]45#include "bncutils.h"
[866]46
47using namespace std;
48
49// Constructor
50////////////////////////////////////////////////////////////////////////////
[875]51RTCM3coDecoder::RTCM3coDecoder(const QString& fileName)
52 : bncZeroDecoder(fileName) {
[866]53}
54
55// Destructor
56////////////////////////////////////////////////////////////////////////////
57RTCM3coDecoder::~RTCM3coDecoder() {
58}
59
60//
61////////////////////////////////////////////////////////////////////////////
62t_irc RTCM3coDecoder::Decode(char* buffer, int bufLen) {
[868]63
[869]64 _buffer.append(buffer, bufLen);
[868]65
[869]66 while (true) {
[908]67
68 memset(&_co, 0, sizeof(_co));
[906]69
[879]70 int bytesused = 0;
71 GCOB_RETURN irc = GetClockOrbitBias(&_co, &_bias, _buffer.data(),
72 _buffer.size(), &bytesused);
73
[906]74 // Not enough Data
75 // ---------------
[879]76 if (irc == GCOBR_SHORTBUFFER ||
[906]77 irc == GCOBR_MESSAGEEXCEEDSBUFFER) {
[869]78 return failure;
79 }
[879]80
[906]81 // Message correctly decoded
82 // -------------------------
[908]83 else if ( (irc == GCOBR_OK || irc == GCOBR_MESSAGEFOLLOWS) &&
84 bytesused > 0) {
[881]85 reopen();
[918]86
87 int GPSweek;
88 double GPSweeks;
89 currentGPSWeeks(GPSweek, GPSweeks);
[919]90
91 if (_co.NumberOfGPSSat > 0) {
92 if (GPSweeks > _co.GPSEpochTime + 86400.0) {
93 GPSweek += 1;
94 }
95 else if (GPSweeks < _co.GPSEpochTime - 86400.0) {
96 GPSweek -= 1;
97 }
98 GPSweeks = _co.GPSEpochTime;
[918]99 }
[919]100 else {
101 double GPSdaysec = fmod(GPSweeks, 86400.0);
102 int weekDay = int((GPSweeks - GPSdaysec) / 86400.0);
103 if (GPSdaysec > _co.GLONASSEpochTime + 3600.0) {
104 weekDay += 1;
105 if (weekDay > 6) {
106 weekDay = 0;
107 GPSweek += 1;
108 }
109 }
110 else if (GPSdaysec < _co.GLONASSEpochTime - 3600.0) {
111 weekDay -= 1;
112 if (weekDay < 0) {
113 weekDay = 6;
114 GPSweek -= 1;
115 }
116 }
117 GPSweeks = weekDay * 86400.0 + _co.GLONASSEpochTime;
[918]118 }
119
[869]120 for(int ii = 0; ii < _co.NumberOfGPSSat; ++ii) {
[875]121 QString line;
[919]122 line.sprintf("%d %.1f G%2.2d %3d %8.3f %8.3f %8.3f %8.3f\n",
[918]123 GPSweek, GPSweeks, _co.Sat[ii].ID, _co.Sat[ii].IOD,
124 _co.Sat[ii].Clock.DeltaA0,
125 _co.Sat[ii].Orbit.DeltaRadial,
126 _co.Sat[ii].Orbit.DeltaAlongTrack,
[869]127 _co.Sat[ii].Orbit.DeltaCrossTrack);
[876]128 *_out << line.toAscii().data();
[869]129 }
[903]130 for(int ii = CLOCKORBIT_NUMGPS;
131 ii < CLOCKORBIT_NUMGPS + _co.NumberOfGLONASSSat; ++ii) {
132 QString line;
[919]133 line.sprintf("%d %.1f R%2.2d %3d %8.3f %8.3f %8.3f %8.3f\n",
[918]134 GPSweek, GPSweeks, _co.Sat[ii].ID, _co.Sat[ii].IOD,
135 _co.Sat[ii].Clock.DeltaA0,
136 _co.Sat[ii].Orbit.DeltaRadial,
137 _co.Sat[ii].Orbit.DeltaAlongTrack,
[903]138 _co.Sat[ii].Orbit.DeltaCrossTrack);
139 *_out << line.toAscii().data();
140 }
141 _out->flush();
[879]142 _buffer = _buffer.substr(bytesused);
[869]143 return success;
144 }
[879]145
[906]146 // All other Cases
147 // ---------------
[869]148 else {
[879]149 _buffer = _buffer.substr(1);
[869]150 }
[868]151 }
[866]152}
Note: See TracBrowser for help on using the repository browser.