[59] | 1 |
|
---|
| 2 | /* -------------------------------------------------------------------------
|
---|
| 3 | * Bernese NTRIP Client
|
---|
| 4 | * -------------------------------------------------------------------------
|
---|
| 5 | *
|
---|
| 6 | * Class: rtigs
|
---|
| 7 | *
|
---|
| 8 | * Purpose: RTIGS Decoder
|
---|
| 9 | *
|
---|
| 10 | * Author: L. Mervart
|
---|
| 11 | *
|
---|
| 12 | * Created: 24-Aug-2006
|
---|
| 13 | *
|
---|
| 14 | * Changes:
|
---|
| 15 | *
|
---|
| 16 | * -----------------------------------------------------------------------*/
|
---|
| 17 |
|
---|
[54] | 18 | #include "rtigs.h"
|
---|
| 19 |
|
---|
[59] | 20 | using namespace std;
|
---|
[54] | 21 |
|
---|
[68] | 22 | #undef L1
|
---|
| 23 | #undef L2
|
---|
| 24 |
|
---|
[59] | 25 | // Constructor
|
---|
[55] | 26 | ////////////////////////////////////////////////////////////////////////////
|
---|
[59] | 27 | rtigs::rtigs() : GPSDecoder() {
|
---|
[55] | 28 | }
|
---|
| 29 |
|
---|
[59] | 30 | // Destructor
|
---|
| 31 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 32 | rtigs::~rtigs() {
|
---|
| 33 | }
|
---|
[54] | 34 |
|
---|
[59] | 35 | //
|
---|
| 36 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 37 | void rtigs::Decode(char* buffer, int bufLen) {
|
---|
| 38 |
|
---|
[66] | 39 | // Append the incomming data to the internal buffer
|
---|
| 40 | // ------------------------------------------------
|
---|
| 41 | _buffer.append( QByteArray(buffer, bufLen) );
|
---|
[54] | 42 |
|
---|
[59] | 43 | // Find the beginning of the message
|
---|
| 44 | // ---------------------------------
|
---|
[66] | 45 | bool found = false;
|
---|
| 46 | for (int ii = 0; ii < _buffer.size(); ii++) {
|
---|
[59] | 47 | unsigned short xx;
|
---|
[66] | 48 | memcpy( (void*) &xx, &_buffer.data()[ii], sizeof(xx) );
|
---|
| 49 | SwitchBytes( (char*) &xx, sizeof(xx) );
|
---|
[59] | 50 | if (xx == 200) {
|
---|
[66] | 51 | _buffer = _buffer.mid(ii);
|
---|
[59] | 52 | found = true;
|
---|
| 53 | break;
|
---|
| 54 | }
|
---|
[54] | 55 | }
|
---|
[59] | 56 | if (! found) {
|
---|
[66] | 57 | _buffer.clear();
|
---|
[59] | 58 | return;
|
---|
[54] | 59 | }
|
---|
[66] | 60 |
|
---|
| 61 | unsigned char* p_buf = (unsigned char*) _buffer.data();
|
---|
| 62 |
|
---|
| 63 | unsigned short messType = _GPSTrans.GetRTIGSHdrRecType(p_buf);
|
---|
| 64 | unsigned short numbytes = _GPSTrans.GetRTIGSHdrRecBytes(p_buf);
|
---|
| 65 |
|
---|
[67] | 66 | // Not enough new data, return
|
---|
| 67 | // ---------------------------
|
---|
[66] | 68 | if (_buffer.size() < numbytes) {
|
---|
| 69 | return;
|
---|
[54] | 70 | }
|
---|
| 71 |
|
---|
[67] | 72 | // Decode the epoch
|
---|
| 73 | // ----------------
|
---|
[61] | 74 | if (messType == 200) {
|
---|
[68] | 75 | RTIGSO_T rtigs_obs;
|
---|
| 76 | short numObs = _GPSTrans.Decode_RTIGS_Obs(p_buf, numbytes, rtigs_obs);
|
---|
[69] | 77 |
|
---|
[68] | 78 | for (short ii = 0; ii < numObs; ii++) {
|
---|
| 79 | Observation* obs = new Observation();
|
---|
| 80 |
|
---|
| 81 | obs->SVPRN = _GPSTrans.DecObs.Obs[ii].sat_prn;
|
---|
[70] | 82 | obs->GPSWeek = _GPSTrans.DecObs.Obs[ii].GPSTime / (7 * 86400);
|
---|
| 83 | obs->GPSWeeks = _GPSTrans.DecObs.Obs[ii].GPSTime % (7 * 86400);
|
---|
| 84 | obs->sec = _GPSTrans.DecObs.Obs[ii].GPSTime % 3600;
|
---|
[84] | 85 | obs->pCodeIndicator = 1;
|
---|
[73] | 86 | obs->C1 = _GPSTrans.DecObs.Obs[ii].p1_pseudo_range;
|
---|
[68] | 87 | obs->P2 = _GPSTrans.DecObs.Obs[ii].p2_pseudo_range;
|
---|
[84] | 88 | obs->L1 = _GPSTrans.DecObs.Obs[ii].p1_phase * (C / F1); // ok
|
---|
| 89 | obs->L2 = _GPSTrans.DecObs.Obs[ii].l1_phase * (C / F1); // strange, probably bug in RTIGS converter
|
---|
[68] | 90 | obs->SNR1 = (short) _GPSTrans.DecObs.Obs[ii].l1_sn * 10;
|
---|
| 91 | obs->SNR2 = (short) _GPSTrans.DecObs.Obs[ii].l2_sn * 10;
|
---|
[73] | 92 | obs->cumuLossOfCont = 0;
|
---|
[68] | 93 |
|
---|
| 94 | m_lObsList.push_back(obs);
|
---|
[54] | 95 | }
|
---|
| 96 | }
|
---|
[66] | 97 |
|
---|
| 98 | // Unprocessed bytes remain in buffer
|
---|
| 99 | // ----------------------------------
|
---|
| 100 | _buffer = _buffer.mid(numbytes);
|
---|
[54] | 101 | }
|
---|