source: ntrip/trunk/BNC/src/GPSS/hassDecoder.cpp@ 5121

Last change on this file since 5121 was 5120, checked in by mervart, 13 years ago
File size: 4.1 KB
RevLine 
[3504]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
[3512]18#include <iostream>
[3579]19
[3504]20#include "hassDecoder.h"
[5070]21#include "bnccore.h"
[3507]22#include "bnctime.h"
[3520]23#include "bncutils.h"
[3579]24#include "bncsettings.h"
[3578]25#include "RTCM3/RTCM3coDecoder.h"
[3504]26
27using namespace std;
28
29// Constructor
30////////////////////////////////////////////////////////////////////////////
[3578]31hassDecoder::hassDecoder(const QString& staID) {
[3579]32 _staID = staID;
33
34 // File Output
35 // -----------
36 bncSettings settings;
37 QString path = settings.value("corrPath").toString();
38 if (!path.isEmpty()) {
39 expandEnvVar(path);
40 if ( path.length() > 0 && path[path.length()-1] != QDir::separator() ) {
41 path += QDir::separator();
42 }
43 _fileNameSkl = path + staID;
44 }
45 _out = 0;
[3506]46 _GPSweeks = -1.0;
[3579]47
[5120]48 connect(this, SIGNAL(newCorrLine(QString, QString, bncTime)),
49 BNC_CORE, SLOT(slotNewCorrLine(QString, QString, bncTime)));
[3504]50}
51
52// Destructor
53////////////////////////////////////////////////////////////////////////////
54hassDecoder::~hassDecoder() {
[3579]55 delete _out;
[3504]56}
57
58//
59////////////////////////////////////////////////////////////////////////////
60t_irc hassDecoder::Decode(char* data, int dataLen, vector<string>& errmsg) {
[3580]61 QMutexLocker locker(&_mutex);
[3504]62
63 errmsg.clear();
64
65 _buffer += QByteArray(data, dataLen);
66
[3506]67 bool corrFound = false;
68 int indexEOL = -1;
69 while ( (indexEOL = _buffer.indexOf('\n')) != -1) {
70 QByteArray line = _buffer.left(indexEOL-1);
[3512]71 _buffer = _buffer.mid(indexEOL+1);
[3504]72
[3512]73 if (QString(line).split(QRegExp("\\s+"), QString::SkipEmptyParts).count() != 11) {
[3506]74 continue;
75 }
76 else {
77 corrFound = true;
78 }
79
80 QTextStream in(line, QIODevice::ReadOnly | QIODevice::Text);
81 int mjd, IOD;
82 double daySec;
[3520]83 ColumnVector dx(3);
84 ColumnVector dxRate(3);
85 double clkFull;
86
[3506]87 QString prn;
88
[3520]89 in >> mjd >> daySec >> prn >> IOD >> dx[0] >> dx[1] >> dx[2] >> clkFull
90 >> dxRate[0] >> dxRate[1] >> dxRate[2];
[3506]91
[3520]92 // Correction Time
93 // ---------------
[5120]94 bncTime coTime; coTime.setmjd(daySec, mjd);
[3507]95
[5120]96 _GPSweeks = coTime.gpssec();
[3507]97
[3520]98 // Transform Correction
99 // --------------------
100 dx = -dx;
101 dxRate = -dxRate;
102
103 t_eph* eph = 0;
104 if (_eph.contains(prn)) {
105 if (_eph.value(prn)->last && _eph.value(prn)->last->IOD() == IOD) {
106 eph = _eph.value(prn)->last;
107 }
108 else if (_eph.value(prn)->prev && _eph.value(prn)->prev->IOD() == IOD) {
109 eph = _eph.value(prn)->prev;
110 }
111 }
112 if (!eph) {
113 continue;
114 }
115
116 ColumnVector xc(4);
117 ColumnVector vv(3);
[5120]118 eph->position(coTime.gpsw(), coTime.gpssec(), xc.data(), vv.data());
[3520]119
120 ColumnVector rao(3);
121 XYZ_to_RSW(xc.Rows(1,3), vv, dx, rao);
122
123 ColumnVector dotRao(3);
124 XYZ_to_RSW(xc.Rows(1,3), vv, dxRate, dotRao);
125
126 double dClk = clkFull - xc[3] * t_CST::c;
127
128 // Print Correction Line
129 // ---------------------
[3507]130 QString corrLine;
131
[3520]132 int updateInterval = 0;
133 int messageType = 0;
[3508]134 if (prn[0] == 'G') {
[3520]135 messageType = COTYPE_GPSCOMBINED;
[3508]136 }
137 else if (prn[0] == 'R') {
[3520]138 messageType = COTYPE_GLONASSCOMBINED;
[3508]139 }
[3507]140
141 corrLine.sprintf("%d %d %d %.1f %s"
142 " %3d"
143 " %8.3f %8.3f %8.3f %8.3f"
144 " %10.5f %10.5f %10.5f %10.5f"
145 " %10.5f",
[5120]146 messageType, updateInterval, coTime.gpsw(), _GPSweeks,
[3507]147 prn.toAscii().data(), IOD,
[3520]148 dClk, rao[0], rao[1], rao[2],
149 0.0, dotRao[0], dotRao[1], dotRao[2], 0.0);
[3514]150
[3578]151 RTCM3coDecoder::reopen(_fileNameSkl, _fileName, _out);
152 if (_out) {
153 *_out << corrLine.toAscii().data() << endl;
154 _out->flush();
155 }
156 emit newCorrLine(corrLine, _staID, coTime);
[3506]157 }
158
159 if (corrFound) {
160 return success;
161 }
162 else {
163 return failure;
164 }
[3504]165}
Note: See TracBrowser for help on using the repository browser.