Changeset 1029 in ntrip for trunk/BNC/RTCM


Ignore:
Timestamp:
Aug 8, 2008, 8:02:33 PM (16 years ago)
Author:
mervart
Message:

Back to status of date 20080807

Location:
trunk/BNC/RTCM
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/RTCM/GPSDecoder.h

    r1024 r1029  
    4747  double L1;          // L1 carrier phase (cycles)
    4848  double L2;          // L2 carrier phase (cycles)
    49   int    slip_cnt_L1; // L1 cumulative loss of continuity indicator
    50   int    slip_cnt_L2; // L2 cumulative loss of continuity indicator
    5149  double S1;          // L1 signal-to noise ratio
    5250  double S2;          // L2 signal-to noise ratio
  • trunk/BNC/RTCM/RTCM2.cpp

    r1024 r1029  
    945945  cph_L1.resize(0);        // Carrier phase [m]
    946946  cph_L2.resize(0);        // Carrier phase [m]
    947   slip_L1.resize(0);       // Slip counter
    948   slip_L2.resize(0);       // Slip counter
    949947 
    950948  availability.reset();    // Message status flags
     
    10071005  bool    isGPS,isCAcode,isL1,isOth;
    10081006  int     NSat,idx;
    1009   int     sid,prn,slip_cnt;
     1007  int     sid,prn;
    10101008  double  t,rng,cph;
    10111009
     
    11191117      // Carrier phase measurement (mod 2^23 [cy]; sign matched to range)
    11201118      cph = -P.getBits(iSat*48+40,32)/256.0;
    1121 
    1122       // Slip counter
    1123       slip_cnt = P.getUnsignedBits(iSat*48+35,5);
    11241119
    11251120      // Is this a new PRN?
     
    11371132        cph_L1.push_back(0.0);
    11381133        cph_L2.push_back(0.0);
    1139         slip_L1.push_back(-1);
    1140         slip_L2.push_back(-1);
    11411134      };
    11421135     
    11431136      // Store measurement
    11441137      if (isL1) {
    1145         cph_L1 [idx] = cph;
    1146         slip_L1[idx] = slip_cnt;
     1138        cph_L1[idx] = cph;
    11471139      }
    11481140      else {
    1149         cph_L2 [idx] = cph;
    1150         slip_L2[idx] = slip_cnt;
     1141        cph_L2[idx] = cph;
    11511142      };
    11521143           
     
    13481339
    13491340}; // End of namespace rtcm2
    1350 
    1351 
    1352 
  • trunk/BNC/RTCM/RTCM2.h

    r1024 r1029  
    309309    std::vector<double>  cph_L1;           // Carrier phase on L1 [cy]
    310310    std::vector<double>  cph_L2;           // Carrier phase on L2 [cy]
    311     std::vector<int>     slip_L1;          // Carrier phase slip counter, L1
    312     std::vector<int>     slip_L2;          // Carrier phase slip counter, L1
    313311
    314312  private:
  • trunk/BNC/RTCM/RTCM2Decoder.cpp

    r1027 r1029  
    3939 * -----------------------------------------------------------------------*/
    4040
    41 #include <math.h>
    42 #include <sstream>
    43 #include <iomanip>
    44 
    4541#include "../bncutils.h"
    46 #include "rtcm_utils.h"
    4742#include "GPSDecoder.h"
    4843#include "RTCM2Decoder.h"
    4944
    5045using namespace std;
    51 using namespace rtcm2;
    5246
    5347//
     
    5549//
    5650
    57 RTCM2Decoder::RTCM2Decoder(const std::string& ID) {
    58   _ID = ID;
     51RTCM2Decoder::RTCM2Decoder() {
     52
    5953}
    6054
     
    6458
    6559RTCM2Decoder::~RTCM2Decoder() {
    66   for (t_pairMap::iterator ii = _ephPair.begin(); ii != _ephPair.end(); ii++) {
    67     delete ii->second;
    68   }
    6960}
    7061
     62//
    7163
    72 //
    73 t_irc RTCM2Decoder::getStaCrd(double& xx, double& yy, double& zz) {
    74   if ( !_msg03.validMsg ) {
    75     return failure;
    76   }
    77  
    78   xx = _msg03.x + (_msg22.validMsg ? _msg22.dL1[0] : 0.0);
    79   yy = _msg03.y + (_msg22.validMsg ? _msg22.dL1[1] : 0.0);
    80   zz = _msg03.z + (_msg22.validMsg ? _msg22.dL1[2] : 0.0);
    81 
    82   return success;
    83 }
    84 
    85 
    86 //
    8764t_irc RTCM2Decoder::Decode(char* buffer, int bufLen) {
    8865
     
    11895          _obsList.push_back(obs);
    11996          if (_ObsBlock.PRN[iSat] > 100) {
    120             obs->_o.satNum    = _ObsBlock.PRN[iSat] % 100;
    121             obs->_o.satSys    = 'R';
    122           }                   
    123           else {             
    124             obs->_o.satNum    = _ObsBlock.PRN[iSat];
    125             obs->_o.satSys    = 'G';
    126           }                   
    127           obs->_o.GPSWeek     = epochWeek;
    128           obs->_o.GPSWeeks    = epochSecs;
    129           obs->_o.C1          = _ObsBlock.rng_C1[iSat];
    130           obs->_o.P1          = _ObsBlock.rng_P1[iSat];
    131           obs->_o.P2          = _ObsBlock.rng_P2[iSat];
    132           obs->_o.L1          = _ObsBlock.resolvedPhase_L1(iSat);
    133           obs->_o.L2          = _ObsBlock.resolvedPhase_L2(iSat);
    134           obs->_o.slip_cnt_L1 = _ObsBlock.slip_L1[iSat];
    135           obs->_o.slip_cnt_L2 = _ObsBlock.slip_L2[iSat];
     97            obs->_o.satNum = _ObsBlock.PRN[iSat] % 100;
     98            obs->_o.satSys = 'R';
     99          }
     100          else {
     101            obs->_o.satNum = _ObsBlock.PRN[iSat];
     102            obs->_o.satSys = 'G';
     103          }
     104          obs->_o.GPSWeek  = epochWeek;
     105          obs->_o.GPSWeeks = epochSecs;
     106          obs->_o.C1       = _ObsBlock.rng_C1[iSat];
     107          obs->_o.P1       = _ObsBlock.rng_P1[iSat];
     108          obs->_o.P2       = _ObsBlock.rng_P2[iSat];
     109          obs->_o.L1       = _ObsBlock.resolvedPhase_L1(iSat);
     110          obs->_o.L2       = _ObsBlock.resolvedPhase_L2(iSat);
    136111        }
    137112        _ObsBlock.clear();
    138113      }
    139     }
    140 
    141     else if ( _PP.ID() == 20 || _PP.ID() == 21 ) {
    142       _msg2021.extract(_PP);
    143 
    144       if (_msg2021.valid()) {
    145         translateCorr2Obs();
    146       }
    147     }
    148 
    149     else if ( _PP.ID() == 3 ) {
    150       _msg03.extract(_PP);
    151     }
    152 
    153     else if ( _PP.ID() == 22 ) {
    154       _msg22.extract(_PP);
    155114    }
    156115  }
     
    158117}
    159118
    160 
    161 
    162 void RTCM2Decoder::storeEph(const gpsephemeris& gpseph) {
    163   t_ephGPS* eph = new t_ephGPS; eph->set(&gpseph);
    164 
    165   string prn = eph->prn();
    166 
    167   t_pairMap::iterator ip = _ephPair.find(prn);
    168   if (ip == _ephPair.end() ) {
    169     ip = _ephPair.insert(pair<string, t_ephPair*>(prn, new t_ephPair)).first;
    170   }
    171   t_ephPair* pair = ip->second;
    172 
    173   if ( !pair->eph || eph->isNewerThan(pair->eph) ) {
    174     delete pair->oldEph;
    175     pair->oldEph = pair->eph;
    176     pair->eph    = eph;
    177 
    178     return;
    179   }
    180 
    181   delete eph;
    182 }
    183 
    184 
    185 void RTCM2Decoder::storeEph(const t_ephGPS& gpseph) {
    186   t_ephGPS* eph = new t_ephGPS(gpseph);
    187 
    188   string prn = eph->prn();
    189 
    190   t_pairMap::iterator ip = _ephPair.find(prn);
    191   if (ip == _ephPair.end() ) {
    192     ip = _ephPair.insert(pair<string, t_ephPair*>(prn, new t_ephPair)).first;
    193   }
    194   t_ephPair* pair = ip->second;
    195 
    196   if ( !pair->eph || eph->isNewerThan(pair->eph) ) {
    197     delete pair->oldEph;
    198     pair->oldEph = pair->eph;
    199     pair->eph    = eph;
    200 
    201     return;
    202   }
    203 
    204   delete eph;
    205 }
    206  
    207  
    208 void RTCM2Decoder::translateCorr2Obs() {
    209 
    210   if ( !_msg03.validMsg || !_msg2021.valid() ) {
    211     return;
    212   }
    213 
    214   double stax = _msg03.x + (_msg22.validMsg ? _msg22.dL1[0] : 0.0);
    215   double stay = _msg03.y + (_msg22.validMsg ? _msg22.dL1[1] : 0.0);
    216   double staz = _msg03.z + (_msg22.validMsg ? _msg22.dL1[2] : 0.0);
    217 
    218   int    refWeek;
    219   double refSecs;
    220   currentGPSWeeks(refWeek, refSecs);
    221 
    222   // Resolve receiver time of measurement (see RTCM 2.3, page 4-42, Message 18, Note 1)
    223   // ----------------------------------------------------------------------------------
    224   double hoursec_est  = _msg2021.hoursec();              // estimated time of measurement
    225   double hoursec_rcv  = rint(hoursec_est * 1e2) / 1e2;   // receiver clock reading at hoursec_est 
    226   double rcv_clk_bias = (hoursec_est - hoursec_rcv) * c_light;
    227 
    228   int    GPSWeek;
    229   double GPSWeeks;
    230   resolveEpoch(hoursec_est, refWeek, refSecs,
    231                GPSWeek, GPSWeeks);
    232 
    233   int    GPSWeek_rcv;
    234   double GPSWeeks_rcv;
    235   resolveEpoch(hoursec_rcv, refWeek, refSecs,
    236                GPSWeek_rcv, GPSWeeks_rcv);
    237 
    238   // Loop over all satellites
    239   // ------------------------
    240   for (RTCM2_2021::data_iterator icorr = _msg2021.data.begin();
    241        icorr != _msg2021.data.end(); icorr++) {
    242     const RTCM2_2021::HiResCorr* corr = icorr->second;
    243 
    244     ostringstream oPRN; oPRN.fill('0');
    245 
    246     oPRN <<            (corr->PRN < 200 ? 'G'       : 'R')
    247          << setw(2) << (corr->PRN < 200 ? corr->PRN : corr->PRN - 200);
    248 
    249     string PRN(oPRN.str());
    250 
    251     t_pairMap::const_iterator ieph = _ephPair.find(PRN);
    252     const t_eph* eph0 = 0;
    253     const t_eph* eph1 = 0;
    254 
    255     if ( ieph != _ephPair.end() ) {
    256       eph0 = ieph->second->eph;
    257       eph1 = ieph->second->oldEph;
    258     }
    259 
    260 
    261     if ( !eph0 && !eph1 ) {
    262       continue;
    263     }
    264 
    265     double L1 = 0;
    266     double L2 = 0;
    267     double P1 = 0;
    268     double P2 = 0;
    269     string obsT = "";
    270 
    271     // new observation
    272     p_obs new_obs = 0;
    273 
    274     for (unsigned ii = 0; ii < 4; ii++) {
    275       int          IODcorr = 0;
    276       double       corrVal = 0;
    277       const t_eph* eph     = 0;
    278       double*      obsVal  = 0;
    279 
    280       switch (ii) {
    281       case 0: // --- L1 ---
    282         IODcorr = corr->IODp1;
    283         corrVal = corr->phase1 * LAMBDA_1;
    284         obsVal  = &L1;
    285         obsT    = "L1";
    286         break;
    287       case 1: // --- L2 ---
    288         IODcorr = corr->IODp2;
    289         corrVal = corr->phase2 * LAMBDA_2;
    290         obsVal  = &L2;
    291         obsT    = "L2";
    292         break;
    293       case 2: // --- P1 ---
    294         IODcorr = corr->IODr1;
    295         corrVal = corr->range1;
    296         obsVal  = &P1;
    297         obsT    = "P1";
    298         break;
    299       case 3: // --- P2 ---
    300         IODcorr = corr->IODr2;
    301         corrVal = corr->range2;
    302         obsVal  = &P2;
    303         obsT    = "P2";
    304         break;
    305       default:
    306         continue;
    307       }
    308 
    309       eph = 0;
    310       if      ( eph0 && eph0->IOD() == IODcorr )
    311         eph = eph0;
    312       else if ( eph1 && eph1->IOD() == IODcorr )
    313         eph = eph1;
    314       if ( eph && corr ) {
    315         int    GPSWeek_tot;
    316         double GPSWeeks_tot;
    317         double rho, xSat, ySat, zSat, clkSat;
    318         cmpRho(eph, stax, stay, staz,
    319                GPSWeek, GPSWeeks,
    320                rho, GPSWeek_tot, GPSWeeks_tot,
    321                xSat, ySat, zSat, clkSat);
    322 
    323         *obsVal = rho - corrVal + rcv_clk_bias - clkSat;
    324 
    325         if ( *obsVal == 0 )  *obsVal = ZEROVALUE;
    326 
    327         // Allocate new memory
    328         // -------------------
    329         if ( !new_obs ) {
    330           new_obs = new t_obs();
    331 
    332           new_obs->_o.StatID[0] = '\x0';
    333           new_obs->_o.satSys    = (corr->PRN < 200 ? 'G'       : 'R');
    334           new_obs->_o.satNum    = (corr->PRN < 200 ? corr->PRN : corr->PRN - 200);
    335          
    336           new_obs->_o.GPSWeek   = GPSWeek_rcv;
    337           new_obs->_o.GPSWeeks  = GPSWeeks_rcv;
    338         }
    339        
    340         // Store estimated measurements
    341         // ----------------------------
    342         switch (ii) {
    343         case 0: // --- L1 ---
    344           new_obs->_o.L1 = *obsVal / LAMBDA_1;
    345           new_obs->_o.slip_cnt_L1 = corr->lock1;
    346           break;
    347         case 1: // --- L2 ---
    348           new_obs->_o.L2 = *obsVal / LAMBDA_2;
    349           new_obs->_o.slip_cnt_L2 = corr->lock2;
    350           break;
    351         case 2: // --- C1 / P1 ---
    352           if ( corr->Pind1 )
    353             new_obs->_o.P1 = *obsVal;
    354           else
    355             new_obs->_o.C1 = *obsVal;
    356           break;
    357         case 3: // --- C2 / P2 ---
    358           if ( corr->Pind2 )
    359             new_obs->_o.P2 = *obsVal;
    360           else
    361             new_obs->_o.C2 = *obsVal;
    362           break;
    363         default:
    364           continue;
    365         }
    366       }
    367     } // loop over frequencies
    368    
    369     if ( new_obs ) {
    370       _obsList.push_back( new_obs );
    371     }
    372   }
    373 }
  • trunk/BNC/RTCM/RTCM2Decoder.h

    r1024 r1029  
    2626#define INC_RTCM2DECODER_H
    2727
    28 #include <list>
    29 
    3028#include "GPSDecoder.h"
    3129#include "RTCM2.h"
    32 #include "RTCM2_2021.h"
    33 #include "../RTCM3/rtcm3torinex.h"
    34 #include "../RTCM3/ephemeris.h"
    3530
    3631class RTCM2Decoder: public GPSDecoder {
    3732
    3833  public:
    39     RTCM2Decoder(const std::string& ID);
     34    RTCM2Decoder();
    4035    virtual ~RTCM2Decoder();
    4136    virtual t_irc Decode(char* buffer, int bufLen);
    4237
    43     void  storeEph(const gpsephemeris& gpseph);
    44     void  storeEph(const t_ephGPS&     gpseph);
    45 
    46     t_irc getStaCrd(double& xx, double& yy, double& zz);
    47 
    48     const rtcm2::RTCM2_2021& msg2021() const { return _msg2021; }
    49 
    5038  private:
    5139
    52     class t_ephPair {
    53     public:
    54       t_ephPair() {
    55         eph    = 0;
    56         oldEph = 0;
    57       }
    58      
    59       ~t_ephPair() {
    60         delete eph;
    61         delete oldEph;
    62       }
    63      
    64       t_eph* eph;
    65       t_eph* oldEph;
    66     };
     40    std::string        _buffer;
     41    rtcm2::RTCM2_Obs   _ObsBlock;
     42    rtcm2::RTCM2packet _PP;
    6743
    68     void translateCorr2Obs();
    69 
    70     std::string            _ID;
    71 
    72     std::string            _buffer;
    73     rtcm2::RTCM2packet     _PP;
    74 
    75     // for messages 18, 19 decoding
    76     rtcm2::RTCM2_Obs       _ObsBlock;
    77 
    78     // for messages 20, 21 decoding
    79     rtcm2::RTCM2_03           _msg03;
    80     rtcm2::RTCM2_22           _msg22;
    81     rtcm2::RTCM2_2021         _msg2021;
    82     std::map<std::string, t_ephPair*> _ephPair;
    83 
    84     typedef std::map<std::string, t_ephPair*> t_pairMap;
    8544};
    8645
Note: See TracChangeset for help on using the changeset viewer.