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

Last change on this file since 236 was 234, checked in by mervart, 18 years ago

* empty log message *

File size: 2.8 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"
[226]19#include "bncconst.h"
[54]20
[59]21using namespace std;
[54]22
[68]23#undef L1
24#undef L2
25
[59]26// Constructor
[55]27////////////////////////////////////////////////////////////////////////////
[59]28rtigs::rtigs() : GPSDecoder() {
[55]29}
30
[59]31// Destructor
32////////////////////////////////////////////////////////////////////////////
33rtigs::~rtigs() {
34}
[54]35
[59]36//
37////////////////////////////////////////////////////////////////////////////
38void rtigs::Decode(char* buffer, int bufLen) {
39
[66]40 // Append the incomming data to the internal buffer
41 // ------------------------------------------------
42 _buffer.append( QByteArray(buffer, bufLen) );
[54]43
[59]44 // Find the beginning of the message
45 // ---------------------------------
[66]46 bool found = false;
47 for (int ii = 0; ii < _buffer.size(); ii++) {
[59]48 unsigned short xx;
[66]49 memcpy( (void*) &xx, &_buffer.data()[ii], sizeof(xx) );
[97]50 if (_GPSTrans.f_IsLittleEndian) {
51 SwitchBytes( (char*) &xx, sizeof(xx) );
52 }
[59]53 if (xx == 200) {
[66]54 _buffer = _buffer.mid(ii);
[59]55 found = true;
56 break;
57 }
[54]58 }
[97]59
[59]60 if (! found) {
[66]61 _buffer.clear();
[59]62 return;
[54]63 }
[66]64
65 unsigned char* p_buf = (unsigned char*) _buffer.data();
66
67 unsigned short messType = _GPSTrans.GetRTIGSHdrRecType(p_buf);
68 unsigned short numbytes = _GPSTrans.GetRTIGSHdrRecBytes(p_buf);
69
[67]70 // Not enough new data, return
71 // ---------------------------
[66]72 if (_buffer.size() < numbytes) {
73 return;
[54]74 }
75
[67]76 // Decode the epoch
77 // ----------------
[61]78 if (messType == 200) {
[68]79 RTIGSO_T rtigs_obs;
80 short numObs = _GPSTrans.Decode_RTIGS_Obs(p_buf, numbytes, rtigs_obs);
[69]81
[68]82 for (short ii = 0; ii < numObs; ii++) {
83 Observation* obs = new Observation();
84
[222]85 obs->SVPRN = _GPSTrans.DecObs.Obs[ii].sat_prn;
86 obs->GPSWeek = _GPSTrans.DecObs.Obs[ii].GPSTime / (7 * 86400);
87 obs->GPSWeeks = _GPSTrans.DecObs.Obs[ii].GPSTime % (7 * 86400);
88 obs->C1 = _GPSTrans.DecObs.Obs[ii].l1_pseudo_range;
89 obs->P1 = _GPSTrans.DecObs.Obs[ii].p1_pseudo_range;
90 obs->P2 = _GPSTrans.DecObs.Obs[ii].p2_pseudo_range;
[234]91 obs->L1 = _GPSTrans.DecObs.Obs[ii].p1_phase;
92 obs->L2 = _GPSTrans.DecObs.Obs[ii].p2_phase;
[226]93 obs->SNR1 = int(_GPSTrans.DecObs.Obs[ii].l1_sn * 10);
94 obs->SNR2 = int(_GPSTrans.DecObs.Obs[ii].l2_sn * 10);
[68]95
[222]96 _obsList.push_back(obs);
[54]97 }
98 }
[66]99
100 // Unprocessed bytes remain in buffer
101 // ----------------------------------
102 _buffer = _buffer.mid(numbytes);
[54]103}
Note: See TracBrowser for help on using the repository browser.