source: ntrip/trunk/BNC/src/RTCM/GPSDecoder.cpp@ 4774

Last change on this file since 4774 was 4774, checked in by mervart, 11 years ago
File size: 4.3 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: GPSDecoder
30 *
31 * Purpose: Decoder Base Class
32 *
33 * Author: L. Mervart
34 *
35 * Created: 16-Dec-2011
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <iomanip>
42#include <cmath>
43
44#include "GPSDecoder.h"
45#include "bncsettings.h"
46
47extern "C" {
48#include "rtcm3torinex.h"
49#include "rtcm3torinexsupport.h"
50}
51
52using namespace std;
53
54// Constructor
55//////////////////////////////////////////////////////////////////////////////
56GPSDecoder::GPSDecoder() {
57 _rnx = 0;
58}
59
60// Initialize RINEX Writer
61//////////////////////////////////////////////////////////////////////////////
62void GPSDecoder::initRinex(const QByteArray& staID, const QUrl& mountPoint,
63 const QByteArray& latitude,
64 const QByteArray& longitude, const QByteArray& nmea,
65 const QByteArray& ntripVersion) {
66 if (_rnx) {
67 return;
68 }
69 bncSettings settings;
70 if ( !settings.value("rnxPath").toString().isEmpty() ) {
71 _rnx = new bncRinex(staID, mountPoint, latitude, longitude,
72 nmea, ntripVersion);
73 }
74}
75
76// Write RINEX Epoch
77//////////////////////////////////////////////////////////////////////////////
78void GPSDecoder::dumpRinexEpoch(const t_obs& obs, const QByteArray& format) {
79 if (_rnx) {
80 long iSec = long(floor(obs.GPSWeeks+0.5));
81 long obsTime = obs.GPSWeek * 7*24*3600 + iSec;
82 if (_rnx->samplingRate() == 0 || iSec % _rnx->samplingRate() == 0) {
83 _rnx->deepCopy(obs);
84 }
85 _rnx->dumpEpoch(format, obsTime);
86 }
87}
88
89// Set RINEX Reconnect Flag
90//////////////////////////////////////////////////////////////////////////////
91void GPSDecoder::setRinexReconnectFlag(bool flag) {
92 if (_rnx) {
93 _rnx->setReconnectFlag(flag);
94 }
95}
96
97//
98//////////////////////////////////////////////////////////////////////////////
99void t_obs::setMeasdata(const QString& rnxStr, float rnxVers, double value) {
100 int ie = iEntry(rnxStr, rnxVers);
101 if (ie != -1) {
102 _measdata[ie] = value;
103 }
104}
105
106//
107//////////////////////////////////////////////////////////////////////////////
108double t_obs::measdata(const QString& rnxStr, float rnxVers) const {
109 int ie = iEntry(rnxStr, rnxVers);
110 if (ie != -1) {
111 return _measdata[ie];
112 }
113 else {
114 return 0.0;
115 }
116}
117
118//
119//////////////////////////////////////////////////////////////////////////////
120int t_obs::iEntry(QString rnxStr, float rnxVers) const {
121
122 if (rnxVers < 3.0) {
123 if (rnxStr == "C1") rnxStr = "C1C";
124 else if (rnxStr == "P1") rnxStr = "C1P";
125 else if (rnxStr == "C2") rnxStr = "C2C";
126 else if (rnxStr == "P2") rnxStr = "C2P";
127 }
128
129 return rrinex3codetoentry(rnxStr.toAscii().data());
130}
131
132//
133//////////////////////////////////////////////////////////////////////////////
134QString t_obs::rnxStr(int iEntry) const {
135 QString str(3,' ');
136 switch(iEntry & 3) {
137 case GNSSENTRY_CODE: str[0] = 'C'; break;
138 case GNSSENTRY_PHASE: str[0] = 'L'; break;
139 case GNSSENTRY_DOPPLER: str[0] = 'D'; break;
140 case GNSSENTRY_SNR: str[0] = 'S'; break;
141 }
142 if (_codetype[iEntry]) {
143 str[1] = _codetype[iEntry][0];
144 str[2] = _codetype[iEntry][1];
145 }
146 return str.trimmed();
147}
Note: See TracBrowser for help on using the repository browser.