source: ntrip/trunk/BNC/GPSS/hassDecoder.cpp@ 3520

Last change on this file since 3520 was 3520, checked in by mervart, 12 years ago
File size: 3.5 KB
Line 
1
2/* -------------------------------------------------------------------------
3 * BKG NTRIP Client
4 * -------------------------------------------------------------------------
5 *
6 * Class: hassDecoder
7 *
8 * Purpose: Decode Data (PPP Corrections) in HASS Format
9 *
10 * Author: L. Mervart
11 *
12 * Created: 19-Nov-2011
13 *
14 * Changes:
15 *
16 * -----------------------------------------------------------------------*/
17
18#include <iostream>
19#include "hassDecoder.h"
20#include "bnctime.h"
21#include "bncutils.h"
22
23using namespace std;
24
25// Constructor
26////////////////////////////////////////////////////////////////////////////
27hassDecoder::hassDecoder(const QString& staID) : RTCM3coDecoder(staID) {
28 _GPSweeks = -1.0;
29}
30
31// Destructor
32////////////////////////////////////////////////////////////////////////////
33hassDecoder::~hassDecoder() {
34}
35
36//
37////////////////////////////////////////////////////////////////////////////
38t_irc hassDecoder::Decode(char* data, int dataLen, vector<string>& errmsg) {
39
40 errmsg.clear();
41
42 _buffer += QByteArray(data, dataLen);
43
44 bool corrFound = false;
45 int indexEOL = -1;
46 while ( (indexEOL = _buffer.indexOf('\n')) != -1) {
47 QByteArray line = _buffer.left(indexEOL-1);
48 _buffer = _buffer.mid(indexEOL+1);
49
50 if (QString(line).split(QRegExp("\\s+"), QString::SkipEmptyParts).count() != 11) {
51 continue;
52 }
53 else {
54 corrFound = true;
55 }
56
57 QTextStream in(line, QIODevice::ReadOnly | QIODevice::Text);
58 int mjd, IOD;
59 double daySec;
60 ColumnVector dx(3);
61 ColumnVector dxRate(3);
62 double clkFull;
63
64 QString prn;
65
66 in >> mjd >> daySec >> prn >> IOD >> dx[0] >> dx[1] >> dx[2] >> clkFull
67 >> dxRate[0] >> dxRate[1] >> dxRate[2];
68
69 // Correction Time
70 // ---------------
71 bncTime tt;
72 tt.setmjd(daySec, mjd);
73
74 _GPSweeks = tt.gpssec();
75 long coTime = tt.gpsw() * 7*24*3600 + long(floor(_GPSweeks+0.5));
76
77 // Transform Correction
78 // --------------------
79 dx = -dx;
80 dxRate = -dxRate;
81
82 t_eph* eph = 0;
83 if (_eph.contains(prn)) {
84 if (_eph.value(prn)->last && _eph.value(prn)->last->IOD() == IOD) {
85 eph = _eph.value(prn)->last;
86 }
87 else if (_eph.value(prn)->prev && _eph.value(prn)->prev->IOD() == IOD) {
88 eph = _eph.value(prn)->prev;
89 }
90 }
91 if (!eph) {
92 continue;
93 }
94
95 ColumnVector xc(4);
96 ColumnVector vv(3);
97 eph->position(tt.gpsw(), tt.gpssec(), xc.data(), vv.data());
98
99 ColumnVector rao(3);
100 XYZ_to_RSW(xc.Rows(1,3), vv, dx, rao);
101
102 ColumnVector dotRao(3);
103 XYZ_to_RSW(xc.Rows(1,3), vv, dxRate, dotRao);
104
105 double dClk = clkFull - xc[3] * t_CST::c;
106
107 // Print Correction Line
108 // ---------------------
109 QString corrLine;
110
111 int updateInterval = 0;
112 int messageType = 0;
113 if (prn[0] == 'G') {
114 messageType = COTYPE_GPSCOMBINED;
115 }
116 else if (prn[0] == 'R') {
117 messageType = COTYPE_GLONASSCOMBINED;
118 }
119
120 corrLine.sprintf("%d %d %d %.1f %s"
121 " %3d"
122 " %8.3f %8.3f %8.3f %8.3f"
123 " %10.5f %10.5f %10.5f %10.5f"
124 " %10.5f",
125 messageType, updateInterval, tt.gpsw(), _GPSweeks,
126 prn.toAscii().data(), IOD,
127 dClk, rao[0], rao[1], rao[2],
128 0.0, dotRao[0], dotRao[1], dotRao[2], 0.0);
129
130 reopen(_fileNameSkl, _fileName, _out);
131 printLine(corrLine, coTime);
132 }
133
134 if (corrFound) {
135 return success;
136 }
137 else {
138 return failure;
139 }
140}
Note: See TracBrowser for help on using the repository browser.