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

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

* empty log message *

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