source: ntrip/branches/BNC_LM/GPSS/hassDecoder.cpp@ 10573

Last change on this file since 10573 was 3571, checked in by mervart, 13 years ago
File size: 3.6 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 //// beg test
83 continue;
84 //// end test
85 //// t_eph* eph = 0;
86 //// if (_eph.contains(prn)) {
87 //// if (_eph.value(prn)->last && _eph.value(prn)->last->IOD() == IOD) {
88 //// eph = _eph.value(prn)->last;
89 //// }
90 //// else if (_eph.value(prn)->prev && _eph.value(prn)->prev->IOD() == IOD) {
91 //// eph = _eph.value(prn)->prev;
92 //// }
93 //// }
94 //// if (!eph) {
95 //// continue;
96 //// }
97
98 ColumnVector xc(4);
99 ColumnVector vv(3);
100 //// eph->position(tt.gpsw(), tt.gpssec(), xc.data(), vv.data());
101
102 ColumnVector rao(3);
103 XYZ_to_RSW(xc.Rows(1,3), vv, dx, rao);
104
105 ColumnVector dotRao(3);
106 XYZ_to_RSW(xc.Rows(1,3), vv, dxRate, dotRao);
107
108 double dClk = clkFull - xc[3] * t_CST::c;
109
110 // Print Correction Line
111 // ---------------------
112 QString corrLine;
113
114 int updateInterval = 0;
115 int messageType = 0;
116 if (prn[0] == 'G') {
117 messageType = COTYPE_GPSCOMBINED;
118 }
119 else if (prn[0] == 'R') {
120 messageType = COTYPE_GLONASSCOMBINED;
121 }
122
123 corrLine.sprintf("%d %d %d %.1f %s"
124 " %3d"
125 " %8.3f %8.3f %8.3f %8.3f"
126 " %10.5f %10.5f %10.5f %10.5f"
127 " %10.5f",
128 messageType, updateInterval, tt.gpsw(), _GPSweeks,
129 prn.toAscii().data(), IOD,
130 dClk, rao[0], rao[1], rao[2],
131 0.0, dotRao[0], dotRao[1], dotRao[2], 0.0);
132
133 reopen(_fileNameSkl, _fileName, _out);
134 printLine(corrLine, coTime);
135 }
136
137 if (corrFound) {
138 return success;
139 }
140 else {
141 return failure;
142 }
143}
Note: See TracBrowser for help on using the repository browser.