Changeset 1021 in ntrip for trunk/BNC/RTCM3/RTCM3Decoder.cpp


Ignore:
Timestamp:
Aug 6, 2008, 12:48:06 PM (16 years ago)
Author:
mervart
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/RTCM3/RTCM3Decoder.cpp

    r970 r1021  
    8383  // -------------------------------------------
    8484  _coDecoder = new RTCM3coDecoder(staID);
     85
     86  // Mode can be either observations or corrections
     87  // ----------------------------------------------
     88  _mode = unknown;
    8589}
    8690
     
    99103  // Try to decode Clock and Orbit Corrections
    100104  // -----------------------------------------
    101   if ( _coDecoder->Decode(buffer, bufLen) == success ) {
    102     decoded = true;
     105  if (_mode == unknown || _mode == corrections) {
     106    if ( _coDecoder->Decode(buffer, bufLen) == success ) {
     107      decoded = true;
     108      if (_mode == unknown) {
     109        _mode = corrections;
     110      }
     111    }
    103112  }
    104113
    105114  // Remaining part decodes the Observations
    106115  // ---------------------------------------
    107   for (int ii = 0; ii < bufLen; ii++) {
    108 
    109     _Parser.Message[_Parser.MessageSize++] = buffer[ii];
    110     if (_Parser.MessageSize >= _Parser.NeedBytes) {
    111 
    112       while(int rr = RTCM3Parser(&_Parser)) {
    113 
    114         // GNSS Observations
    115         // -----------------
    116         if (rr == 1 || rr == 2) {
    117                 decoded = true;
    118 
    119           if (!_Parser.init) {
    120             HandleHeader(&_Parser);
    121             _Parser.init = 1;
    122           }
    123          
    124           if (rr == 2) {
    125             std::cerr << "No valid RINEX! All values are modulo 299792.458!\n";
    126           }
    127          
    128           for (int ii = 0; ii < _Parser.Data.numsats; ii++) {
    129             p_obs obs = new t_obs();
    130             _obsList.push_back(obs);
    131             if      (_Parser.Data.satellites[ii] <= PRN_GPS_END) {
    132               obs->_o.satSys = 'G';
    133               obs->_o.satNum = _Parser.Data.satellites[ii];
    134             }
    135             else if (_Parser.Data.satellites[ii] <= PRN_GLONASS_END) {
    136               obs->_o.satSys = 'R';
    137               obs->_o.satNum = _Parser.Data.satellites[ii] - PRN_GLONASS_START + 1;
    138             }
    139             else {
    140               obs->_o.satSys = 'S';
    141               obs->_o.satNum = _Parser.Data.satellites[ii] - PRN_WAAS_START + 20;
    142             }
    143             obs->_o.GPSWeek  = _Parser.Data.week;
    144             obs->_o.GPSWeeks = _Parser.Data.timeofweek / 1000.0;
    145          
    146             for (int jj = 0; jj < _Parser.numdatatypesGPS; jj++) {
    147               int v = 0;
    148 // sepearated declaration and initalization of df and pos. Perlt
    149               int df;
    150               int pos;
    151               df = _Parser.dataflag[jj];
    152               pos = _Parser.datapos[jj];
    153               if ( (_Parser.Data.dataflags[ii] & df)
    154                    && !isnan(_Parser.Data.measdata[ii][pos])
    155                    && !isinf(_Parser.Data.measdata[ii][pos])) {
    156                 v = 1;
     116  if (_mode == unknown || _mode == observations) {
     117    for (int ii = 0; ii < bufLen; ii++) {
     118   
     119      _Parser.Message[_Parser.MessageSize++] = buffer[ii];
     120      if (_Parser.MessageSize >= _Parser.NeedBytes) {
     121   
     122        while(int rr = RTCM3Parser(&_Parser)) {
     123   
     124          // GNSS Observations
     125          // -----------------
     126          if (rr == 1 || rr == 2) {
     127                  decoded = true;
     128   
     129            if (!_Parser.init) {
     130              HandleHeader(&_Parser);
     131              _Parser.init = 1;
     132            }
     133           
     134            if (rr == 2) {
     135              std::cerr << "No valid RINEX! All values are modulo 299792.458!\n";
     136            }
     137           
     138            for (int ii = 0; ii < _Parser.Data.numsats; ii++) {
     139              p_obs obs = new t_obs();
     140              _obsList.push_back(obs);
     141              if      (_Parser.Data.satellites[ii] <= PRN_GPS_END) {
     142                obs->_o.satSys = 'G';
     143                obs->_o.satNum = _Parser.Data.satellites[ii];
     144              }
     145              else if (_Parser.Data.satellites[ii] <= PRN_GLONASS_END) {
     146                obs->_o.satSys = 'R';
     147                obs->_o.satNum = _Parser.Data.satellites[ii] - PRN_GLONASS_START + 1;
    157148              }
    158149              else {
    159                 df = _Parser.dataflagGPS[jj];
    160                 pos = _Parser.dataposGPS[jj];
     150                obs->_o.satSys = 'S';
     151                obs->_o.satNum = _Parser.Data.satellites[ii] - PRN_WAAS_START + 20;
     152              }
     153              obs->_o.GPSWeek  = _Parser.Data.week;
     154              obs->_o.GPSWeeks = _Parser.Data.timeofweek / 1000.0;
     155           
     156              for (int jj = 0; jj < _Parser.numdatatypesGPS; jj++) {
     157                int v = 0;
     158                // sepearated declaration and initalization of df and pos. Perlt
     159                int df;
     160                int pos;
     161                df = _Parser.dataflag[jj];
     162                pos = _Parser.datapos[jj];
    161163                if ( (_Parser.Data.dataflags[ii] & df)
    162164                     && !isnan(_Parser.Data.measdata[ii][pos])
    163165                     && !isinf(_Parser.Data.measdata[ii][pos])) {
    164                 v = 1;
    165                 }
    166               }
    167               if (!v) {
    168                 continue;
    169               }
    170               else
    171               {
    172 // variables df and pos are used consequently. Perlt
    173                 if      (df & GNSSDF_C1DATA) {
    174                   obs->_o.C1 = _Parser.Data.measdata[ii][pos];
    175                 }
    176                 else if (df & GNSSDF_C2DATA) {
    177                   obs->_o.C2 = _Parser.Data.measdata[ii][pos];
    178                 }
    179                 else if (df & GNSSDF_P1DATA) {
    180                   obs->_o.P1 = _Parser.Data.measdata[ii][pos];
    181                 }
    182                 else if (df & GNSSDF_P2DATA) {
    183                   obs->_o.P2 = _Parser.Data.measdata[ii][pos];
    184                 }
    185                 else if (df & (GNSSDF_L1CDATA|GNSSDF_L1PDATA)) {
    186                   obs->_o.L1   = _Parser.Data.measdata[ii][pos];
    187                   obs->_o.SNR1 = _Parser.Data.snrL1[ii];
    188                 }
    189                 else if (df & (GNSSDF_L2CDATA|GNSSDF_L2PDATA)) {
    190                   obs->_o.L2   = _Parser.Data.measdata[ii][pos];
    191                   obs->_o.SNR2 = _Parser.Data.snrL2[ii];
    192                 }
    193                 else if (df & (GNSSDF_S1CDATA|GNSSDF_S1PDATA)) {
    194                   obs->_o.S1   = _Parser.Data.measdata[ii][pos];
    195                 }
    196                 else if (df & (GNSSDF_S2CDATA|GNSSDF_S2PDATA)) {
    197                   obs->_o.S2   = _Parser.Data.measdata[ii][pos];
     166                  v = 1;
     167                }
     168                else {
     169                  df = _Parser.dataflagGPS[jj];
     170                  pos = _Parser.dataposGPS[jj];
     171                  if ( (_Parser.Data.dataflags[ii] & df)
     172                       && !isnan(_Parser.Data.measdata[ii][pos])
     173                       && !isinf(_Parser.Data.measdata[ii][pos])) {
     174                  v = 1;
     175                  }
     176                }
     177                if (!v) {
     178                  continue;
     179                }
     180                else
     181                {
     182                  // variables df and pos are used consequently. Perlt
     183                  if      (df & GNSSDF_C1DATA) {
     184                    obs->_o.C1 = _Parser.Data.measdata[ii][pos];
     185                  }
     186                  else if (df & GNSSDF_C2DATA) {
     187                    obs->_o.C2 = _Parser.Data.measdata[ii][pos];
     188                  }
     189                  else if (df & GNSSDF_P1DATA) {
     190                    obs->_o.P1 = _Parser.Data.measdata[ii][pos];
     191                  }
     192                  else if (df & GNSSDF_P2DATA) {
     193                    obs->_o.P2 = _Parser.Data.measdata[ii][pos];
     194                  }
     195                  else if (df & (GNSSDF_L1CDATA|GNSSDF_L1PDATA)) {
     196                    obs->_o.L1   = _Parser.Data.measdata[ii][pos];
     197                    obs->_o.SNR1 = _Parser.Data.snrL1[ii];
     198                  }
     199                  else if (df & (GNSSDF_L2CDATA|GNSSDF_L2PDATA)) {
     200                    obs->_o.L2   = _Parser.Data.measdata[ii][pos];
     201                    obs->_o.SNR2 = _Parser.Data.snrL2[ii];
     202                  }
     203                  else if (df & (GNSSDF_S1CDATA|GNSSDF_S1PDATA)) {
     204                    obs->_o.S1   = _Parser.Data.measdata[ii][pos];
     205                  }
     206                  else if (df & (GNSSDF_S2CDATA|GNSSDF_S2PDATA)) {
     207                    obs->_o.S2   = _Parser.Data.measdata[ii][pos];
     208                  }
    198209                }
    199210              }
    200211            }
    201212          }
    202         }
    203 
    204         // GPS Ephemeris
    205         // -------------
    206         else if (rr == 1019) {
    207           decoded = true;
    208           gpsephemeris* ep = new gpsephemeris(_Parser.ephemerisGPS);
    209           emit newGPSEph(ep);
    210         }
    211 
    212         // GLONASS Ephemeris
    213         // -----------------
    214         else if (rr == 1020) {
    215           decoded = true;
    216           glonassephemeris* ep = new glonassephemeris(_Parser.ephemerisGLONASS);
    217           emit newGlonassEph(ep);
     213   
     214          // GPS Ephemeris
     215          // -------------
     216          else if (rr == 1019) {
     217            decoded = true;
     218            gpsephemeris* ep = new gpsephemeris(_Parser.ephemerisGPS);
     219            emit newGPSEph(ep);
     220          }
     221   
     222          // GLONASS Ephemeris
     223          // -----------------
     224          else if (rr == 1020) {
     225            decoded = true;
     226            glonassephemeris* ep = new glonassephemeris(_Parser.ephemerisGLONASS);
     227            emit newGlonassEph(ep);
     228          }
    218229        }
    219230      }
    220231    }
    221   }
    222   if (!decoded) {
    223   return failure;
     232    if (_mode == unknown && decoded) {
     233      _mode = observations;
     234    }
     235  }
     236
     237  if (decoded) {
     238    return success;
    224239  }
    225240  else {
    226   return success;
    227   }
    228 }
     241    return failure;
     242  }
     243}
Note: See TracChangeset for help on using the changeset viewer.