[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>
|
---|
[3504] | 19 | #include "hassDecoder.h"
|
---|
[3507] | 20 | #include "bnctime.h"
|
---|
[3520] | 21 | #include "bncutils.h"
|
---|
[3504] | 22 |
|
---|
| 23 | using namespace std;
|
---|
| 24 |
|
---|
| 25 | // Constructor
|
---|
| 26 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3505] | 27 | hassDecoder::hassDecoder(const QString& staID) : RTCM3coDecoder(staID) {
|
---|
[3506] | 28 | _GPSweeks = -1.0;
|
---|
[3504] | 29 | }
|
---|
| 30 |
|
---|
| 31 | // Destructor
|
---|
| 32 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 33 | hassDecoder::~hassDecoder() {
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | //
|
---|
| 37 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 38 | t_irc hassDecoder::Decode(char* data, int dataLen, vector<string>& errmsg) {
|
---|
| 39 |
|
---|
| 40 | errmsg.clear();
|
---|
| 41 |
|
---|
| 42 | _buffer += QByteArray(data, dataLen);
|
---|
| 43 |
|
---|
[3506] | 44 | bool corrFound = false;
|
---|
| 45 | int indexEOL = -1;
|
---|
| 46 | while ( (indexEOL = _buffer.indexOf('\n')) != -1) {
|
---|
| 47 | QByteArray line = _buffer.left(indexEOL-1);
|
---|
[3512] | 48 | _buffer = _buffer.mid(indexEOL+1);
|
---|
[3504] | 49 |
|
---|
[3512] | 50 | if (QString(line).split(QRegExp("\\s+"), QString::SkipEmptyParts).count() != 11) {
|
---|
[3506] | 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;
|
---|
[3520] | 60 | ColumnVector dx(3);
|
---|
| 61 | ColumnVector dxRate(3);
|
---|
| 62 | double clkFull;
|
---|
| 63 |
|
---|
[3506] | 64 | QString prn;
|
---|
| 65 |
|
---|
[3520] | 66 | in >> mjd >> daySec >> prn >> IOD >> dx[0] >> dx[1] >> dx[2] >> clkFull
|
---|
| 67 | >> dxRate[0] >> dxRate[1] >> dxRate[2];
|
---|
[3506] | 68 |
|
---|
[3520] | 69 | // Correction Time
|
---|
| 70 | // ---------------
|
---|
[3507] | 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 |
|
---|
[3520] | 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 | // ---------------------
|
---|
[3507] | 109 | QString corrLine;
|
---|
| 110 |
|
---|
[3520] | 111 | int updateInterval = 0;
|
---|
| 112 | int messageType = 0;
|
---|
[3508] | 113 | if (prn[0] == 'G') {
|
---|
[3520] | 114 | messageType = COTYPE_GPSCOMBINED;
|
---|
[3508] | 115 | }
|
---|
| 116 | else if (prn[0] == 'R') {
|
---|
[3520] | 117 | messageType = COTYPE_GLONASSCOMBINED;
|
---|
[3508] | 118 | }
|
---|
[3507] | 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,
|
---|
[3520] | 127 | dClk, rao[0], rao[1], rao[2],
|
---|
| 128 | 0.0, dotRao[0], dotRao[1], dotRao[2], 0.0);
|
---|
[3514] | 129 |
|
---|
| 130 | reopen(_fileNameSkl, _fileName, _out);
|
---|
[3507] | 131 | printLine(corrLine, coTime);
|
---|
[3506] | 132 | }
|
---|
| 133 |
|
---|
| 134 | if (corrFound) {
|
---|
| 135 | return success;
|
---|
| 136 | }
|
---|
| 137 | else {
|
---|
| 138 | return failure;
|
---|
| 139 | }
|
---|
[3504] | 140 | }
|
---|