source: ntrip/trunk/BNC/RTIGS/rtigs.cpp@ 119

Last change on this file since 119 was 97, checked in by mervart, 18 years ago

* empty log message *

File size: 2.9 KB
RevLine 
[59]1
2/* -------------------------------------------------------------------------
[93]3 * BKG NTRIP Client
[59]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]20using namespace std;
[54]21
[68]22#undef L1
23#undef L2
24
[59]25// Constructor
[55]26////////////////////////////////////////////////////////////////////////////
[59]27rtigs::rtigs() : GPSDecoder() {
[55]28}
29
[59]30// Destructor
31////////////////////////////////////////////////////////////////////////////
32rtigs::~rtigs() {
33}
[54]34
[59]35//
36////////////////////////////////////////////////////////////////////////////
37void 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) );
[97]49 if (_GPSTrans.f_IsLittleEndian) {
50 SwitchBytes( (char*) &xx, sizeof(xx) );
51 }
[59]52 if (xx == 200) {
[66]53 _buffer = _buffer.mid(ii);
[59]54 found = true;
55 break;
56 }
[54]57 }
[97]58
[59]59 if (! found) {
[66]60 _buffer.clear();
[59]61 return;
[54]62 }
[66]63
64 unsigned char* p_buf = (unsigned char*) _buffer.data();
65
66 unsigned short messType = _GPSTrans.GetRTIGSHdrRecType(p_buf);
67 unsigned short numbytes = _GPSTrans.GetRTIGSHdrRecBytes(p_buf);
68
[67]69 // Not enough new data, return
70 // ---------------------------
[66]71 if (_buffer.size() < numbytes) {
72 return;
[54]73 }
74
[67]75 // Decode the epoch
76 // ----------------
[61]77 if (messType == 200) {
[68]78 RTIGSO_T rtigs_obs;
79 short numObs = _GPSTrans.Decode_RTIGS_Obs(p_buf, numbytes, rtigs_obs);
[69]80
[68]81 for (short ii = 0; ii < numObs; ii++) {
82 Observation* obs = new Observation();
83
84 obs->SVPRN = _GPSTrans.DecObs.Obs[ii].sat_prn;
[70]85 obs->GPSWeek = _GPSTrans.DecObs.Obs[ii].GPSTime / (7 * 86400);
86 obs->GPSWeeks = _GPSTrans.DecObs.Obs[ii].GPSTime % (7 * 86400);
87 obs->sec = _GPSTrans.DecObs.Obs[ii].GPSTime % 3600;
[84]88 obs->pCodeIndicator = 1;
[73]89 obs->C1 = _GPSTrans.DecObs.Obs[ii].p1_pseudo_range;
[68]90 obs->P2 = _GPSTrans.DecObs.Obs[ii].p2_pseudo_range;
[84]91 obs->L1 = _GPSTrans.DecObs.Obs[ii].p1_phase * (C / F1); // ok
92 obs->L2 = _GPSTrans.DecObs.Obs[ii].l1_phase * (C / F1); // strange, probably bug in RTIGS converter
[68]93 obs->SNR1 = (short) _GPSTrans.DecObs.Obs[ii].l1_sn * 10;
94 obs->SNR2 = (short) _GPSTrans.DecObs.Obs[ii].l2_sn * 10;
[73]95 obs->cumuLossOfCont = 0;
[68]96
97 m_lObsList.push_back(obs);
[54]98 }
99 }
[66]100
101 // Unprocessed bytes remain in buffer
102 // ----------------------------------
103 _buffer = _buffer.mid(numbytes);
[54]104}
Note: See TracBrowser for help on using the repository browser.