Changeset 7629 in ntrip


Ignore:
Timestamp:
Dec 10, 2015, 3:35:44 PM (8 years ago)
Author:
stuerze
Message:

some value initialization in constructor is added

Location:
trunk/BNC/src/RTCM
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/RTCM/RTCM2.cpp

    r6788 r7629  
    22//
    33// RTCM2.cpp
    4 // 
    5 // Purpose: 
     4//
     5// Purpose:
    66//
    77//   Module for extraction of RTCM2 messages
     
    1111//   RTCM 10402.3 Recommended Standards for Differential GNSS (Global
    1212//     Navigation Satellite Systems) Service; RTCM Paper 136-2001/SC104-STD,
    13 //     Version 2.3, 20 Aug. 2001; Radio Technical Commission For Maritime 
     13//     Version 2.3, 20 Aug. 2001; Radio Technical Commission For Maritime
    1414//     Services, Alexandria, Virgina (2001).
    1515//   ICD-GPS-200; Navstar GPS Space Segment / Navigation User Interfaces;
     
    2222//     last accessed 17 Sep. 2006
    2323//
    24 // Notes: 
     24// Notes:
    2525//
    2626// - The host computer is assumed to use little endian (Intel) byte order
     
    3636//   2006/10/14  LMV  Exception handling
    3737//   2006/10/17  OMO  Removed obsolete check of multiple message indicator
    38 //   2006/10/17  OMO  Fixed parity handling 
     38//   2006/10/17  OMO  Fixed parity handling
    3939//   2006/10/18  OMO  Improved screening of bad data in RTCM2_Obs::extract
    4040//   2006/11/25  OMO  Revised check for presence of GLONASS data
    4141//   2007/05/25  GW   Round time tag to 100 ms
    42 //   2007/12/11  AHA  Changed handling of C/A- and P-Code on L1 
    43 //   2007/12/13  AHA  Changed epoch comparison in packet extraction 
     42//   2007/12/11  AHA  Changed handling of C/A- and P-Code on L1
     43//   2007/12/13  AHA  Changed epoch comparison in packet extraction
    4444//   2008/03/01  OMO  Compilation flag for epoch rounding
    4545//   2008/03/04  AHA  Fixed problems with PRN 32
    4646//   2008/03/05  AHA  Implemeted fix for Trimble 4000SSI receivers
    47 //   2008/03/07  AHA  Major revision of input buffer handling 
     47//   2008/03/07  AHA  Major revision of input buffer handling
    4848//   2008/03/07  AHA  Removed unnecessary failure flag
    4949//   2008/03/10  AHA  Corrected extraction of antenna serial number
     
    7676// Note: A need to round the measurement epoch to integer tenths of a second was
    7777// noted by BKG in the processing of RTCM2 data from various receivers in NTRIP
    78 // real-time networks. It is unclear at present, whether this is due to an 
     78// real-time networks. It is unclear at present, whether this is due to an
    7979// improper implementation of the RTCM2 standard in the respective receivers
    80 // or an unclear formulation of the standard. 
     80// or an unclear formulation of the standard.
    8181
    8282#define ROUND_EPOCH  1
     
    8484// Fix for data streams originating from TRIMBLE_4000SSI receivers.
    8585// GPS PRN32 is erroneously flagged as GLONASS satellite in the C/A
    86 // pseudorange messages. We therefore use a majority voting to 
     86// pseudorange messages. We therefore use a majority voting to
    8787// determine the true constellation for this message.
    8888// This fix is only required for Trimble4000SSI receivers but can also
     
    101101
    102102const double lambda_L1 = c_light/f_L1;  // L1 wavelength [m] (0.1903m)
    103 const double lambda_L2 = c_light/f_L2;  // L2 wavelength [m] 
     103const double lambda_L2 = c_light/f_L2;  // L2 wavelength [m]
    104104
    105105//
     
    107107//
    108108
    109 const int bit_L1rngGPS =  0; 
    110 const int bit_L2rngGPS =  1; 
    111 const int bit_L1cphGPS =  2; 
    112 const int bit_L2cphGPS =  3; 
    113 const int bit_L1rngGLO =  4; 
    114 const int bit_L2rngGLO =  5; 
    115 const int bit_L1cphGLO =  6; 
    116 const int bit_L2cphGLO =  7; 
     109const int bit_L1rngGPS =  0;
     110const int bit_L2rngGPS =  1;
     111const int bit_L1cphGPS =  2;
     112const int bit_L2cphGPS =  3;
     113const int bit_L1rngGLO =  4;
     114const int bit_L2rngGLO =  5;
     115const int bit_L1cphGLO =  6;
     116const int bit_L2cphGLO =  7;
    117117
    118118
     
    122122
    123123namespace rtcm2 {
    124  
     124
    125125//------------------------------------------------------------------------------
    126126//
     
    128128//
    129129// Purpose:
    130 // 
     130//
    131131//   Handling of RTCM2 30bit words
    132132//
     
    148148bool ThirtyBitWord::validParity() const {
    149149
    150   // Parity stuff 
     150  // Parity stuff
    151151
    152152  static const unsigned int  PARITY_25 = 0xBB1F3480;
     
    173173
    174174  unsigned int t, w, p;
    175  
    176   // The sign of the data is determined by the D30* parity bit 
    177   // of the previous data word. If  D30* is set, invert the data 
     175
     176  // The sign of the data is determined by the D30* parity bit
     177  // of the previous data word. If  D30* is set, invert the data
    178178  // bits D01..D24 to obtain the d01..d24 (but leave all other
    179179  // bits untouched).
    180  
     180
    181181  w = W;
    182182  if ( w & 0x40000000 )  w ^= 0x3FFFFFC0;
     
    188188  p = ( byteParity[t      &0xff] ^ byteParity[(t>> 8)&0xff] ^
    189189        byteParity[(t>>16)&0xff] ^ byteParity[(t>>24)     ]   );
    190  
     190
    191191  t = w & PARITY_26;
    192   p = (p<<1) | 
     192  p = (p<<1) |
    193193      ( byteParity[t      &0xff] ^ byteParity[(t>> 8)&0xff] ^
    194194        byteParity[(t>>16)&0xff] ^ byteParity[(t>>24)     ]   );
    195  
     195
    196196  t = w & PARITY_27;
    197   p = (p<<1) | 
     197  p = (p<<1) |
    198198      ( byteParity[t      &0xff] ^ byteParity[(t>> 8)&0xff] ^
    199199        byteParity[(t>>16)&0xff] ^ byteParity[(t>>24)     ]   );
    200  
     200
    201201  t = w & PARITY_28;
    202   p = (p<<1) | 
     202  p = (p<<1) |
    203203      ( byteParity[t      &0xff] ^ byteParity[(t>> 8)&0xff] ^
    204204        byteParity[(t>>16)&0xff] ^ byteParity[(t>>24)     ]   );
    205  
     205
    206206  t = w & PARITY_29;
    207   p = (p<<1) | 
     207  p = (p<<1) |
    208208      ( byteParity[t      &0xff] ^ byteParity[(t>> 8)&0xff] ^
    209209        byteParity[(t>>16)&0xff] ^ byteParity[(t>>24)     ]   );
    210  
     210
    211211  t = w & PARITY_30;
    212   p = (p<<1) | 
     212  p = (p<<1) |
    213213      ( byteParity[t      &0xff] ^ byteParity[(t>> 8)&0xff] ^
    214214        byteParity[(t>>16)&0xff] ^ byteParity[(t>>24)     ]   );
     
    224224
    225225  const unsigned char Preamble = 0x66;
    226  
     226
    227227  unsigned char b = (value()>>22) & 0xFF;
    228  
     228
    229229  return ( b==Preamble );
    230230
     
    244244
    245245  unsigned int w = W;
    246    
     246
    247247  if (validParity()) {
    248     // Return data and current parity bits. Invert data bits if D30* 
     248    // Return data and current parity bits. Invert data bits if D30*
    249249    // is set and discard old parity bits.
    250250    if ( w & 0x40000000 )  w ^= 0x3FFFFFC0;
     
    255255    return 0;
    256256  };
    257  
     257
    258258};
    259259
     
    262262
    263263void ThirtyBitWord::append(unsigned char b) {
    264  
     264
    265265  // Look up table for swap (left-right) of 6 data bits
    266   static const unsigned char 
    267     swap[] = {                               
    268       0,32,16,48, 8,40,24,56, 4,36,20,52,12,44,28,60,                         
    269       2,34,18,50,10,42,26,58, 6,38,22,54,14,46,30,62,                         
    270       1,33,17,49, 9,41,25,57, 5,37,21,53,13,45,29,61,                         
    271       3,35,19,51,11,43,27,59, 7,39,23,55,15,47,31,63                         
     266  static const unsigned char
     267    swap[] = {
     268      0,32,16,48, 8,40,24,56, 4,36,20,52,12,44,28,60,
     269      2,34,18,50,10,42,26,58, 6,38,22,54,14,46,30,62,
     270      1,33,17,49, 9,41,25,57, 5,37,21,53,13,45,29,61,
     271      3,35,19,51,11,43,27,59, 7,39,23,55,15,47,31,63
    272272    };
    273    
     273
    274274  // Bits 7 and 6 (of 0..7) must be "01" for valid data bytes
    275275  if ( (b & 0x40) != 0x40 ) {
    276276    // We simply skip the invalid input byte and leave the word unchanged
    277 #if (DEBUG>0) 
     277#if (DEBUG>0)
    278278    cerr << "Error in append()" << bitset<32>(all()) << endl;
    279279#endif
    280280    return;
    281281  };
    282  
     282
    283283  // Swap bits 0..5 to restore proper bit order for 30bit words
    284284  b = swap[ b & 0x3f];
    285285
    286286  // Fill word
    287   W = ( (W <<6) | (b & 0x3f) ) ; 
    288  
     287  W = ( (W <<6) | (b & 0x3f) ) ;
     288
    289289};
    290290
     
    295295
    296296  // Check if string is long enough
    297    
     297
    298298  if (buf.size()<5) {
    299299    // Ignore; users should avoid this case prior to calling get()
    300    
    301 #if ( DEBUG > 0 )   
     300
     301#if ( DEBUG > 0 )
    302302    cerr << "Error in get(): packet too short (" << buf.size() <<")" << endl;
    303303#endif
    304        
     304
    305305    return;
    306306  };
    307  
     307
    308308  // Process 5 bytes
    309  
     309
    310310  for (int i=0; i<5; i++) append(buf[i]);
    311311
    312 #if (DEBUG>0) 
     312#if (DEBUG>0)
    313313  if (!validParity()) {
    314     cerr << "Parity error in get()" 
     314    cerr << "Parity error in get()"
    315315         << bitset<32>(all()) << endl;
    316316  };
     
    326326
    327327  for (int i=0; i<5; i++) {
    328     inp >> b; 
     328    inp >> b;
    329329    if (inp.fail()) { clear(); return; };
    330330    append(b);
    331331  };
    332332
    333 #if (DEBUG>0) 
     333#if (DEBUG>0)
    334334  if (!validParity()) {
    335     cerr << "Parity error in get()" 
     335    cerr << "Parity error in get()"
    336336         << bitset<32>(all()) << endl;
    337337  };
     
    346346  const unsigned int wordLen = 5; // Number of bytes representing a 30-bit word
    347347  const unsigned int spare   = 1; // Number of spare words for resync of parity
    348                                   // (same value as inRTCM2packet::getPacket()) 
     348                                  // (same value as inRTCM2packet::getPacket())
    349349  unsigned int i;
    350  
     350
    351351  i=0;
    352   // append spare word (to get correct parity) and first consecutive word 
     352  // append spare word (to get correct parity) and first consecutive word
    353353  while (i<(spare+1)*wordLen) {
    354354    // Process byte
     
    357357    i++;
    358358  };
    359  
     359
    360360  // start searching for preamble in first word after spare word
    361361  while (!isHeader() && i<buf.size() ) {
     
    370370  if (i>=(1+spare)*wordLen) buf.erase(0,i-(1+spare)*wordLen);
    371371
    372 #if (DEBUG>0) 
     372#if (DEBUG>0)
    373373  if (!validParity()) {
    374     cerr << "Parity error in getHeader()" 
     374    cerr << "Parity error in getHeader()"
    375375         << bitset<32>(all()) << endl;
    376376  };
    377377#endif
    378  
     378
    379379};
    380380
     
    388388  i=0;
    389389  while ( !isHeader() || i<5 ) {
    390     inp >> b; 
     390    inp >> b;
    391391    if (inp.fail()) { clear(); return; };
    392392    append(b); i++;
    393393  };
    394394
    395 #if (DEBUG>0) 
     395#if (DEBUG>0)
    396396  if (!validParity()) {
    397     cerr << "Parity error in getHeader()" 
     397    cerr << "Parity error in getHeader()"
    398398         << bitset<32>(all()) << endl;
    399399  };
     
    422422
    423423void RTCM2packet::clear()  {
    424  
     424
    425425  W.clear();
    426  
     426
    427427  H1=0;
    428428  H2=0;
    429  
     429
    430430  DW.resize(0,0);
    431  
     431
    432432};
    433433
     
    435435
    436436bool RTCM2packet::valid() const {
    437  
     437
    438438  // The methods for creating a packet (get,">>") ensure
    439   // that a packet has a consistent number of data words 
    440   // and a valid parity in all header and data words. 
     439  // that a packet has a consistent number of data words
     440  // and a valid parity in all header and data words.
    441441  // Therefore a packet is either empty or valid.
    442  
     442
    443443  return (H1!=0);
    444    
     444
    445445};
    446446
     
    456456                         // (same value as used in ThirtyBitWord::getHeader)
    457457  unsigned int n;
    458  
     458
    459459  // Does the package content at least spare bytes and first header byte?
    460   if (buf.size()<(spare+1)*wordLen) { 
    461       clear();       
     460  if (buf.size()<(spare+1)*wordLen) {
     461      clear();
    462462      return;
    463463  };
    464    
    465   // Try to read a full packet. Processed bytes are removed from the input 
    466   // buffer except for the latest spare*wordLen bytes to restore the parity 
     464
     465  // Try to read a full packet. Processed bytes are removed from the input
     466  // buffer except for the latest spare*wordLen bytes to restore the parity
    467467  // bytes upon subseqeunt calls of getPacket().
    468  
     468
    469469  // Locate and read the first header word
    470470  W.getHeader(buf);
    471   if (!W.isHeader()) { 
     471  if (!W.isHeader()) {
    472472    // No header found; try again next time. buf retains only the spare
    473473    // words. The packet contents is cleared to indicate an unsuccessful
    474474    // termination of getPacket().
    475475    clear();
    476    
     476
    477477#if ( DEBUG > 0 )
    478478    cerr << "Error in getPacket(): W.isHeader() = false  for H1" << endl;
    479479#endif
    480    
    481     return; 
     480
     481    return;
    482482  };
    483483  H1 = W.value();
    484484
    485   // Do we have enough bytes to read the next word? If not, the packet 
     485  // Do we have enough bytes to read the next word? If not, the packet
    486486  // contents is cleared to indicate an unsuccessful termination. The
    487487  // previously read spare and header bytes are retained in the buffer
    488488  // for use in the next call of getPacket().
    489   if (buf.size()<(spare+2)*wordLen) { 
    490     clear(); 
    491    
    492 #if ( DEBUG > 0 )   
     489  if (buf.size()<(spare+2)*wordLen) {
     490    clear();
     491
     492#if ( DEBUG > 0 )
    493493    cerr << "Error in getPacket(): buffer too short for complete H2" << endl;
    494494#endif
    495    
     495
    496496    return;
    497497  };
    498  
     498
    499499  // Read the second header word
    500   W.get(buf.substr((spare+1)*wordLen,buf.size()-(spare+1)*wordLen)); 
     500  W.get(buf.substr((spare+1)*wordLen,buf.size()-(spare+1)*wordLen));
    501501  H2 = W.value();
    502   if (!W.validParity()) { 
     502  if (!W.validParity()) {
    503503    // Invalid H2 word; delete first buffer byte and try to resynch next time.
    504504    // The packet contents is cleared to indicate an unsuccessful termination.
    505     clear(); 
    506     buf.erase(0,1); 
    507    
    508 #if ( DEBUG > 0 )   
     505    clear();
     506    buf.erase(0,1);
     507
     508#if ( DEBUG > 0 )
    509509    cerr << "Error in getPacket(): W.validParity() = false for H2" << endl;
    510510#endif
    511        
    512     return; 
     511
     512    return;
    513513  };
    514514
    515515  n = nDataWords();
    516  
    517   // Do we have enough bytes to read the next word? If not, the packet 
     516
     517  // Do we have enough bytes to read the next word? If not, the packet
    518518  // contents is cleared to indicate an unsuccessful termination. The
    519519  // previously read spare and header bytes are retained in the buffer
    520520  // for use in the next call of getPacket().
    521   if (buf.size()<(spare+2+n)*wordLen) { 
    522     clear(); 
    523    
    524 #if ( DEBUG > 0 )   
     521  if (buf.size()<(spare+2+n)*wordLen) {
     522    clear();
     523
     524#if ( DEBUG > 0 )
    525525    cerr << "Error in getPacket(): buffer too short for complete " << n
    526526         << " DWs" << endl;
    527527#endif
    528    
    529     return; 
    530   };
    531  
     528
     529    return;
     530  };
     531
    532532  DW.resize(n);
    533533  for (unsigned int i=0; i<n; i++) {
    534     W.get(buf.substr((spare+2+i)*wordLen,buf.size()-(spare+2+i)*wordLen)); 
     534    W.get(buf.substr((spare+2+i)*wordLen,buf.size()-(spare+2+i)*wordLen));
    535535    DW[i] = W.value();
    536     if (!W.validParity()) { 
     536    if (!W.validParity()) {
    537537      // Invalid data word; delete first byte and try to resynch next time.
    538538      // The packet contents is cleared to indicate an unsuccessful termination.
    539       clear(); 
    540       buf.erase(0,1); 
    541      
    542 #if ( DEBUG > 0 )   
     539      clear();
     540      buf.erase(0,1);
     541
     542#if ( DEBUG > 0 )
    543543    cerr << "Error in getPacket(): W.validParity() = false for DW"
    544544         << i << endl;
    545545#endif
    546        
    547       return; 
     546
     547      return;
    548548    };
    549549  };
    550550
    551   // Successful packet extraction; delete total number of message bytes 
    552   // from buffer. 
     551  // Successful packet extraction; delete total number of message bytes
     552  // from buffer.
    553553  // Note: a total of "spare" words remain in the buffer to enable a
    554554  // parity resynchronization when searching the next header.
    555  
     555
    556556  buf.erase(0,(n+2)*wordLen);
    557    
     557
    558558  return;
    559  
     559
    560560};
    561561
     
    568568
    569569  int n;
    570  
    571   W.getHeader(inp); 
    572   H1 = W.value(); 
     570
     571  W.getHeader(inp);
     572  H1 = W.value();
    573573  if (inp.fail() || !W.isHeader()) { clear(); return; }
    574  
    575   W.get(inp);       
    576   H2 = W.value(); 
     574
     575  W.get(inp);
     576  H2 = W.value();
    577577  if (inp.fail() || !W.validParity()) { clear(); return; }
    578578
     
    580580  DW.resize(n);
    581581  for (int i=0; i<n; i++) {
    582     W.get(inp); 
    583     DW[i] = W.value(); 
     582    W.get(inp);
     583    DW[i] = W.value();
    584584    if (inp.fail() || !W.validParity()) { clear(); return; }
    585585  };
    586586
    587587  return;
    588  
     588
    589589};
    590590
     
    592592// Input operator
    593593//
    594 // Reads an RTCM2 packet from the input stream. 
     594// Reads an RTCM2 packet from the input stream.
    595595//
    596596
     
    598598
    599599  p.getPacket(is);
    600  
     600
    601601  return is;
    602  
     602
    603603};
    604604
     
    653653//
    654654
    655 unsigned int RTCM2packet::getUnsignedBits ( unsigned int start, 
     655unsigned int RTCM2packet::getUnsignedBits ( unsigned int start,
    656656                                            unsigned int n      ) const {
    657                                    
     657
    658658  unsigned int  iFirst = start/24;       // Index of first data word
    659659  unsigned int  iLast  = (start+n-1)/24; // Index of last  data word
    660660  unsigned int  bitField = 0;
    661661  unsigned int  tmp;
    662  
     662
    663663  // Checks
    664  
     664
    665665  if (n>32) {
    666666    throw("Error: can't handle >32 bits in RTCM2packet::getUnsignedBits");
    667667  };
    668  
     668
    669669  if ( 24*DW.size() < start+n-1 ) {
    670670#if (DEBUG>0)
     
    683683
    684684  // Handle initial data word
    685   // Get all data bits. Strip parity and unwanted leading bits. 
    686   // Store result in 24 lsb bits of tmp. 
    687  
    688   tmp = (DW[iFirst]>>6) & 0xFFFFFF; 
     685  // Get all data bits. Strip parity and unwanted leading bits.
     686  // Store result in 24 lsb bits of tmp.
     687
     688  tmp = (DW[iFirst]>>6) & 0xFFFFFF;
    689689  tmp = ( ( tmp << start%24) & 0xFFFFFF ) >> start%24 ;
    690690
    691691  // Handle central data word
    692  
    693   if ( iFirst<iLast ) { 
     692
     693  if ( iFirst<iLast ) {
    694694    bitField = tmp;
    695695    for (unsigned int iWord=iFirst+1; iWord<iLast; iWord++) {
    696       tmp = (DW[iWord]>>6) & 0xFFFFFF;     
     696      tmp = (DW[iWord]>>6) & 0xFFFFFF;
    697697      bitField = (bitField << 24) | tmp;
    698698    };
    699     tmp = (DW[iLast]>>6) & 0xFFFFFF;     
     699    tmp = (DW[iLast]>>6) & 0xFFFFFF;
    700700  };
    701701
    702702  // Handle last data word
    703  
     703
    704704  tmp = tmp >> (23-(start+n-1)%24);
    705705  bitField = (bitField << ((start+n-1)%24+1)) | tmp;
    706706
    707707  // Done
    708  
     708
    709709  return bitField;
    710  
     710
    711711};
    712712
     
    717717//
    718718
    719 int RTCM2packet::getBits ( unsigned int start, 
     719int RTCM2packet::getBits ( unsigned int start,
    720720                           unsigned int n      ) const {
    721721
    722722
    723723  // Checks
    724  
     724
    725725  if (n>32) {
    726726    throw("Error: can't handle >32 bits in RTCM2packet::getBits");
    727727  };
    728  
     728
    729729  if ( 24*DW.size() < start+n-1 ) {
    730730#if (DEBUG>0)
     
    743743
    744744  return ((int)(getUnsignedBits(start,n)<<(32-n))>>(32-n));
    745  
     745
    746746};
    747747
     
    757757//------------------------------------------------------------------------------
    758758
    759 // Constructor
    760 RTCM2_03::RTCM2_03(){
    761   validMsg = false;
    762   x = 0.0;
    763   y = 0.0;
    764   z=0.0;
    765 };
    766759
    767760void RTCM2_03::extract(const RTCM2packet& P) {
    768761
    769762  // Check validity, packet type and number of data words
    770  
    771   validMsg = (P.valid()); 
     763
     764  validMsg = (P.valid());
    772765  if (!validMsg) return;
    773766
    774   validMsg = (P.ID()==03); 
     767  validMsg = (P.ID()==03);
    775768  if (!validMsg) return;
    776  
    777   validMsg = (P.nDataWords()==4); 
     769
     770  validMsg = (P.nDataWords()==4);
    778771  if (!validMsg) return;
    779  
     772
    780773  // Antenna reference point coordinates
    781  
     774
    782775  x  = P.getBits( 0,32)*0.01;    // X [m]
    783776  y  = P.getBits(32,32)*0.01;    // Y [m]
     
    799792
    800793  unsigned int       nad, nas;
    801  
     794
    802795  const unsigned int nF1  = 8; // bits in first field (R,AF,SF,NAD)
    803796  const unsigned int nF2  =16; // bits in second field (SETUP ID,R,NAS)
    804797  const unsigned int nBits=24; // data bits in  30bit word
    805  
     798
    806799  // Check validity, packet type and number of data words
    807  
    808   validMsg = (P.valid()); 
     800
     801  validMsg = (P.valid());
    809802  if (!validMsg) return;
    810803
    811   validMsg = (P.ID()==23); 
     804  validMsg = (P.ID()==23);
    812805  if (!validMsg) return;
    813806
    814807  // Check number of data words (can nad be read in?)
    815  
    816   validMsg = (P.nDataWords()>=1); 
     808
     809  validMsg = (P.nDataWords()>=1);
    817810  if (!validMsg){
    818811    cerr << "RTCM2_23::extract: P.nDataWords()>=1" << endl;
     
    820813  }
    821814
    822   // Antenna descriptor 
     815  // Antenna descriptor
    823816  antType = "";
    824817  nad = P.getUnsignedBits(3,5);
    825  
    826   // Check number of data words (can antenna description be read in?) 
    827   validMsg = ( P.nDataWords() >= 
     818
     819  // Check number of data words (can antenna description be read in?)
     820  validMsg = ( P.nDataWords() >=
    828821               (unsigned int)ceil((nF1+nad*8)/(double)nBits) );
    829822
    830823  if (!validMsg) return;
    831  
    832   for (unsigned int i=0;i<nad;i++) 
     824
     825  for (unsigned int i=0;i<nad;i++)
    833826    antType += (char)P.getUnsignedBits(nF1+i*8,8);
    834827
     
    837830
    838831    // Check number of data words (can nas be read in?)
    839    
     832
    840833    validMsg = ( P.nDataWords() >=
    841834                 (unsigned int)ceil((nF1+nad*8+nF2)/(double)nBits) );
    842835    if (!validMsg) return;
    843    
     836
    844837    nas = P.getUnsignedBits(19+8*nad,5);
    845838
    846839    // Check number of data words (can antenna serial number be read in?)
    847    
     840
    848841    validMsg = ( P.nDataWords() >=
    849842                 (unsigned int)ceil((nF1+nad*8+nF2+nas*8)/(double)nBits) );
     
    851844
    852845    antSN = "";
    853     for (unsigned int i=0;i<nas;i++) 
     846    for (unsigned int i=0;i<nas;i++)
    854847      antSN += (char)P.getUnsignedBits(nF1+8*nad+nF2+i*8,8);
    855848  };
     
    864857// Purpose:
    865858//
    866 //   A class for handling RTCM 2 Reference Station Antenna 
     859//   A class for handling RTCM 2 Reference Station Antenna
    867860//   Reference Point Parameter messages
    868861//
     
    874867
    875868  // Check validity, packet type and number of data words
    876  
    877   validMsg = (P.valid()); 
     869
     870  validMsg = (P.valid());
    878871  if (!validMsg) return;
    879872
    880   validMsg = (P.ID()==24); 
     873  validMsg = (P.ID()==24);
    881874  if (!validMsg) return;
    882  
    883   validMsg = (P.nDataWords()==6); 
     875
     876  validMsg = (P.nDataWords()==6);
    884877  if (!validMsg) return;
    885  
     878
    886879  // System indicator
    887  
     880
    888881  isGPS     = (P.getUnsignedBits(118,1)==0);
    889882  isGLONASS = (P.getUnsignedBits(118,1)==1);
    890  
     883
    891884  // Antenna reference point coordinates
    892885
     
    902895
    903896  // Antenna Height
    904    
     897
    905898  if (P.getUnsignedBits(119,1)==1) {
    906899    h= P.getUnsignedBits(120,18)*0.0001;
     
    917910// Purpose:
    918911//
    919 //   A class for handling blocks of RTCM2 18 & 19 packets that need to be 
     912//   A class for handling blocks of RTCM2 18 & 19 packets that need to be
    920913//   combined to get a complete set of measurements
    921914//
     
    923916//
    924917//   The class collects L1/L2 code and phase measurements for GPS and GLONASS.
    925 //   Since the Multiple Message Indicator is inconsistently handled by various 
     918//   Since the Multiple Message Indicator is inconsistently handled by various
    926919//   receivers we simply require code and phase on L1 and L2 for a complete
    927 //   set ob observations at a given epoch. GLONASS observations are optional, 
    928 //   but all four types (code+phase,L1+L2) must be provided, if at least one 
    929 //   is given. Also, the GLONASS message must follow the corresponding GPS 
     920//   set ob observations at a given epoch. GLONASS observations are optional,
     921//   but all four types (code+phase,L1+L2) must be provided, if at least one
     922//   is given. Also, the GLONASS message must follow the corresponding GPS
    930923//   message.
    931924//
     
    940933};
    941934
    942 // Reset entire block 
     935// Reset entire block
    943936
    944937void RTCM2_Obs::clear() {
    945  
     938
    946939  GPSonly = true;
    947  
     940
    948941  secs=0.0;                // Seconds of hour (GPS time)
    949942  nSat=0;                  // Number of space vehicles
     
    956949  slip_L1.resize(0);       // Slip counter
    957950  slip_L2.resize(0);       // Slip counter
    958  
     951
    959952  availability.reset();    // Message status flags
    960  
     953
    961954};
    962955
     
    969962          availability.test(bit_L1cphGPS) ||
    970963          availability.test(bit_L2cphGPS);
    971    
     964
    972965};
    973966
     
    978971          availability.test(bit_L1cphGLO) ||
    979972          availability.test(bit_L2cphGLO);
    980    
     973
    981974};
    982975
     
    987980          availability.test(bit_L1cphGPS) &&
    988981          availability.test(bit_L2cphGPS);
    989    
     982
    990983};
    991984
     
    996989          availability.test(bit_L1cphGLO) &&
    997990          availability.test(bit_L2cphGLO);
    998    
     991
    999992};
    1000993
     
    1004997
    1005998  return ( allGPS() && ( GPSonly || allGLONASS() ) );
    1006  
     999
    10071000};
    10081001
     
    10201013
    10211014  // Check validity and packet type
    1022  
    1023   if ( ! ( P.valid() && 
     1015
     1016  if ( ! ( P.valid() &&
    10241017           (P.ID()==18 || P.ID()==19) ) ) return;
    10251018
    1026   // Check number of data words, message starts with 1 DW for epoch, then each 
    1027   // satellite brings 2 DW, 
     1019  // Check number of data words, message starts with 1 DW for epoch, then each
     1020  // satellite brings 2 DW,
    10281021  // Do not start decoding if less than 3 DW are in package
    1029  
     1022
    10301023  if ( P.nDataWords()<3 ) {
    10311024#if ( DEBUG > 0 )
     
    10331026         << P.nDataWords() << ") detected" << endl;
    10341027#endif
    1035    
     1028
    10361029    return;
    10371030  };
    1038  
     1031
    10391032  // Check if number of data words is odd number
    1040  
     1033
    10411034  if ( P.nDataWords()%2==0 ){
    10421035#if ( DEBUG > 0 )
     
    10441037         << P.nDataWords() << ") detected" << endl;
    10451038#endif
    1046    
     1039
    10471040    return;
    10481041  };
    1049  
     1042
    10501043  // Clear previous data if block was already complete
    10511044
    10521045  if (valid()) clear();
    1053  
    1054   // Process carrier phase message       
    1055  
    1056   if ( P.ID()==18 ) {   
    1057    
     1046
     1047  // Process carrier phase message
     1048
     1049  if ( P.ID()==18 ) {
     1050
    10581051    // Number of satellites in current message
    1059     NSat = (P.nDataWords()-1)/2; 
    1060 
    1061     // Current epoch (mod 3600 sec) 
    1062     t = 0.6*P.modZCount() 
     1052    NSat = (P.nDataWords()-1)/2;
     1053
     1054    // Current epoch (mod 3600 sec)
     1055    t = 0.6*P.modZCount()
    10631056        + P.getUnsignedBits(4,20)*1.0e-6;
    1064    
     1057
    10651058#if (ROUND_EPOCH==1)
    10661059    // SC-104 V2.3 4-42 Note 1 4. Assume measurements at hard edges
     
    10751068    isOth = ( P.getUnsignedBits(1,1)==1 );
    10761069    if (isOth) return;
    1077      
     1070
    10781071    // Constellation (for first satellite in message)
    10791072    isGPS = ( P.getUnsignedBits(26,1)==0 );
    10801073    GPSonly = GPSonly && isGPS;
    1081    
     1074
    10821075    // Multiple Message Indicator (only checked for first satellite)
    10831076    // pendingMsg = ( P.getUnsignedBits(24,1)==1 );
    1084    
    1085     // Handle epoch: store epoch of first GPS message and 
     1077
     1078    // Handle epoch: store epoch of first GPS message and
    10861079    // check consistency of subsequent messages. GLONASS time tags
    10871080    // are different and have to be ignored
    10881081    if (isGPS) {
    10891082      if ( nSat==0 ) {
    1090         secs = t; // Store epoch 
     1083        secs = t; // Store epoch
    10911084      }
    10921085//    else if (t!=secs) {
    10931086      else if (abs(t-secs)>1e-6) {
    1094         clear(); secs = t; // Clear all data, then store epoch 
     1087        clear(); secs = t; // Clear all data, then store epoch
    10951088      };
    10961089    };
    10971090
    1098     // Discard GLONASS observations if no prior GPS observations 
    1099     // are available 
     1091    // Discard GLONASS observations if no prior GPS observations
     1092    // are available
    11001093    if (!isGPS && !anyGPS() ) return;
    1101        
     1094
    11021095    // Set availability flags
    1103    
     1096
    11041097    if ( isL1 &&  isGPS) availability.set(bit_L1cphGPS);
    11051098    if (!isL1 &&  isGPS) availability.set(bit_L2cphGPS);
    11061099    if ( isL1 && !isGPS) availability.set(bit_L1cphGLO);
    11071100    if (!isL1 && !isGPS) availability.set(bit_L2cphGLO);
    1108    
     1101
    11091102#if ( DEBUG > 0 )
    1110     cerr << "RTCM2_Obs::extract(): availability " 
    1111          << bitset<8>(availability) << endl; 
    1112 #endif
    1113    
    1114    
     1103    cerr << "RTCM2_Obs::extract(): availability "
     1104         << bitset<8>(availability) << endl;
     1105#endif
     1106
     1107
    11151108    // Process all satellites
    1116    
     1109
    11171110    for (int iSat=0;iSat<NSat;iSat++){
    11181111
    11191112      // Code type
    11201113      isCAcode = ( P.getUnsignedBits(iSat*48+25,1)==0 );
    1121      
    1122       // Satellite 
     1114
     1115      // Satellite
    11231116      sid = P.getUnsignedBits(iSat*48+27,5);
    11241117      if (sid==0) sid=32;
    1125      
     1118
    11261119      prn = (isGPS? sid : sid+200 );
    1127      
     1120
    11281121      // Carrier phase measurement (mod 2^23 [cy]; sign matched to range)
    11291122      cph = -P.getBits(iSat*48+40,32)/256.0;
     
    11491142        slip_L2.push_back(-1);
    11501143      };
    1151      
     1144
    11521145      // Store measurement
    11531146      if (isL1) {
     
    11591152        slip_L2[idx] = slip_cnt;
    11601153      };
    1161            
     1154
    11621155    };
    1163  
    1164   };
    1165 
    1166 
    1167   // Process pseudorange message       
    1168  
    1169   if ( P.ID()==19 ) {   
    1170  
     1156
     1157  };
     1158
     1159
     1160  // Process pseudorange message
     1161
     1162  if ( P.ID()==19 ) {
     1163
    11711164    // Number of satellites in current message
    1172     NSat = (P.nDataWords()-1)/2; 
    1173 
    1174     // Current epoch (mod 3600 sec) 
    1175     t = 0.6*P.modZCount() 
     1165    NSat = (P.nDataWords()-1)/2;
     1166
     1167    // Current epoch (mod 3600 sec)
     1168    t = 0.6*P.modZCount()
    11761169        + P.getUnsignedBits(4,20)*1.0e-6;
    1177    
     1170
    11781171#if (ROUND_EPOCH==1)
    11791172    // SC-104 V2.3 4-42 Note 1 4. Assume measurements at hard edges
     
    11881181    isOth = ( P.getUnsignedBits(1,1)==1 );
    11891182    if (isOth) return;
    1190      
     1183
    11911184#if (FIX_TRIMBLE_4000SSI==1)
    11921185    // Fix for data streams originating from TRIMBLE_4000SSI receivers.
    11931186    // GPS PRN32 is erroneously flagged as GLONASS satellite in the C/A
    1194     // pseudorange messages. We therefore use a majority voting to 
     1187    // pseudorange messages. We therefore use a majority voting to
    11951188    // determine the true constellation for this message.
    11961189    // This fix is only required for Trimble4000SSI receivers but can also
     
    12021195      if(isGPS) nGPS++;
    12031196    };
    1204     isGPS = (2*nGPS>NSat); 
     1197    isGPS = (2*nGPS>NSat);
    12051198#else
    12061199    // Constellation (for first satellite in message)
     
    12111204    // Multiple Message Indicator (only checked for first satellite)
    12121205    // pendingMsg = ( P.getUnsignedBits(24,1)==1 );
    1213    
    1214     // Handle epoch: store epoch of first GPS message and 
     1206
     1207    // Handle epoch: store epoch of first GPS message and
    12151208    // check consistency of subsequent messages. GLONASS time tags
    12161209    // are different and have to be ignored
    12171210    if (isGPS) {
    12181211      if ( nSat==0 ) {
    1219         secs = t; // Store epoch 
     1212        secs = t; // Store epoch
    12201213      }
    12211214//    else if (t!=secs) {
    12221215      else if (abs(t-secs)>1e-6) {
    1223         clear(); secs = t; // Clear all data, then store epoch 
     1216        clear(); secs = t; // Clear all data, then store epoch
    12241217      };
    12251218    };
    12261219
    1227     // Discard GLONASS observations if no prior GPS observations 
    1228     // are available 
     1220    // Discard GLONASS observations if no prior GPS observations
     1221    // are available
    12291222    if (!isGPS && !anyGPS() ) return;
    1230        
     1223
    12311224    // Set availability flags
    12321225    if ( isL1 &&  isGPS) availability.set(bit_L1rngGPS);
     
    12361229
    12371230#if ( DEBUG > 0 )
    1238     cerr << "RTCM2_Obs::extract(): availability " 
    1239          << bitset<8>(availability) << endl; 
     1231    cerr << "RTCM2_Obs::extract(): availability "
     1232         << bitset<8>(availability) << endl;
    12401233#endif
    12411234
    12421235    // Process all satellites
    1243    
     1236
    12441237    for (int iSat=0;iSat<NSat;iSat++){
    12451238
    12461239      // Code type
    12471240      isCAcode = ( P.getUnsignedBits(iSat*48+25,1)==0 );
    1248      
    1249       // Satellite 
     1241
     1242      // Satellite
    12501243      sid = P.getUnsignedBits(iSat*48+27,5);
    12511244      if (sid==0) sid=32;
    12521245      prn = (isGPS? sid : sid+200 );
    1253      
     1246
    12541247      // Pseudorange measurement [m]
    12551248      rng = P.getUnsignedBits(iSat*48+40,32)*0.02;
     
    12721265              slip_L2.push_back(-1);
    12731266      };
    1274      
     1267
    12751268      // Store measurement
    12761269      if (isL1) {
     
    12791272        }
    12801273        else {
    1281           rng_P1[idx] = rng; 
     1274          rng_P1[idx] = rng;
    12821275        }
    12831276      }
     
    12851278        rng_P2[idx] = rng;
    12861279      };
    1287            
     1280
    12881281    };
    1289  
    1290   };
    1291 
    1292 };
    1293 
    1294 //
    1295 //  Resolution of 2^24 cy carrier phase ambiguity 
     1282
     1283  };
     1284
     1285};
     1286
     1287//
     1288//  Resolution of 2^24 cy carrier phase ambiguity
    12961289//  caused by 32-bit data field restrictions
    1297 // 
     1290//
    12981291//  Note: the RTCM standard specifies an ambiguity of +/-2^23 cy.
    12991292//  However, numerous receivers generate data in the +/-2^22 cy range.
     
    13041297
    13051298//const double  ambig = pow(2.0,24);   // as per RTCM2 spec
    1306   const double  ambig = pow(2.0,23);   // used by many receivers 
     1299  const double  ambig = pow(2.0,23);   // used by many receivers
    13071300
    13081301  double        rng;
    13091302  double        n;
    1310  
     1303
    13111304  if (!valid() || i<0 || i>nSat-1) return 0.0;
    13121305
    1313   rng = rng_C1[i]; 
     1306  rng = rng_C1[i];
    13141307  if (rng==0.0) rng = rng_P1[i];
    13151308  if (rng==0.0) return 0.0;
    1316  
     1309
    13171310  n = floor( (rng/lambda_L1-cph_L1[i]) / ambig + 0.5 );
    1318  
     1311
    13191312  return cph_L1[i] + n*ambig;
    1320  
    1321 }; 
     1313
     1314};
    13221315
    13231316double RTCM2_Obs::resolvedPhase_L2(int i) const {
    13241317
    13251318//const double  ambig = pow(2.0,24);   // as per RTCM2 spec
    1326   const double  ambig = pow(2.0,23);   // used by many receivers 
     1319  const double  ambig = pow(2.0,23);   // used by many receivers
    13271320
    13281321  double        rng;
    13291322  double        n;
    1330  
     1323
    13311324  if (!valid() || i<0 || i>nSat-1) return 0.0;
    1332  
    1333   rng = rng_C1[i]; 
     1325
     1326  rng = rng_C1[i];
    13341327  if (rng==0.0) rng = rng_P1[i];
    13351328  if (rng==0.0) return 0.0;
    1336  
     1329
    13371330  n = floor( (rng/lambda_L2-cph_L2[i]) / ambig + 0.5 );
    1338  
     1331
    13391332  return cph_L2[i] + n*ambig;
    1340  
    1341 }; 
     1333
     1334};
    13421335
    13431336//
    13441337//  Resolution of epoch using reference date (GPS week and secs)
    1345 // 
    1346 
    1347 void RTCM2_Obs::resolveEpoch (int  refWeek,   double  refSecs, 
     1338//
     1339
     1340void RTCM2_Obs::resolveEpoch (int  refWeek,   double  refSecs,
    13481341                              int& epochWeek, double& epochSecs   ) const {
    13491342
    1350   const double secsPerWeek = 604800.0;                           
     1343  const double secsPerWeek = 604800.0;
    13511344
    13521345  epochWeek = refWeek;
    13531346  epochSecs = secs + 3600.0*(floor((refSecs-secs)/3600.0+0.5));
    1354  
     1347
    13551348  if (epochSecs<0          ) { epochWeek--; epochSecs+=secsPerWeek; };
    13561349  if (epochSecs>secsPerWeek) { epochWeek++; epochSecs-=secsPerWeek; };
    1357                              
     1350
    13581351};
    13591352
  • trunk/BNC/src/RTCM/RTCM2.h

    r1105 r7629  
    22//
    33// RTCM2.h
    4 // 
    5 // Purpose: 
     4//
     5// Purpose:
    66//
    77//   Module for extraction of RTCM2 messages
     
    1111//   RTCM 10402.3 Recommended Standards for Differential GNSS (Global
    1212//     Navigation Satellite Systems) Service; RTCM Paper 136-2001/SC104-STD,
    13 //     Version 2.3, 20 Aug. 2001; Radio Technical Commission For Maritime 
     13//     Version 2.3, 20 Aug. 2001; Radio Technical Commission For Maritime
    1414//     Services, Alexandria, Virgina (2001).
    1515//   ICD-GPS-200; Navstar GPS Space Segment / Navigation User Interfaces;
     
    3838#define INC_RTCM2_H
    3939
    40 #include <bitset> 
     40#include <bitset>
    4141#include <fstream>
    4242#include <string>
     
    5555//
    5656// Purpose:
    57 // 
     57//
    5858//   Handling of RTCM2 30bit words
    5959//
     
    6363
    6464  public:
    65  
     65
    6666    // Constructor and initialization
    67    
     67
    6868    ThirtyBitWord();
    69    
     69
    7070    void         clear();
    7171
    7272    // Status queries
    73    
     73
    7474    bool         fail() const;
    7575    bool         validParity() const;
     
    7777
    7878    // Access methods
    79    
     79
    8080    unsigned int all() const;
    8181    unsigned int value() const;
    82    
     82
    8383    // Input
    84    
     84
    8585    void         get(const std::string& buf);
    8686    void         get(std::istream& inp);
    8787    void         getHeader(std::string& buf);
    8888    void         getHeader(std::istream& inp);
    89  
    90   private:
    91      
     89
     90  private:
     91
    9292    // Input
    9393
     
    102102    // parity bits retained from the previous word
    103103    //
    104     // Bits 31..30 (from left to right) hold the parity bits D29*..D30* of 
     104    // Bits 31..30 (from left to right) hold the parity bits D29*..D30* of
    105105    //             the previous 30-bit word
    106106    // Bits 29..06 (from left to right) hold the current data bits D01..D24
     
    108108    //
    109109
    110     unsigned int W;         
    111      
     110    unsigned int W;
     111
    112112};
    113113
     
    125125
    126126class RTCM2packet {
    127  
    128   public:
    129  
     127
     128  public:
     129
    130130    // Constructor and initialization
    131    
     131
    132132    RTCM2packet();
    133    
     133
    134134    void clear();
    135    
     135
    136136    // Status queries
    137137
    138     bool valid() const; 
    139    
    140     // Input 
     138    bool valid() const;
     139
     140    // Input
    141141
    142142    void                 getPacket(std::string&  buf);
    143143    void                 getPacket(std::istream& inp);
    144144    friend std::istream& operator >> (std::istream& is, RTCM2packet& p);
    145    
     145
    146146    //
    147147    // Access methods
    148     //   
    149    
     148    //
     149
    150150    // Header and data words contents (parity corrected)
    151    
     151
    152152    unsigned int  header1() const;
    153153    unsigned int  header2() const;
    154154    unsigned int  dataWord(int i) const;
    155    
     155
    156156    // Header information
    157    
     157
    158158    unsigned int  msgType()    const;
    159159    unsigned int  ID()         const { return msgType(); };
     
    174174
    175175    // All input of RTCM data uses a single instance, W, of a 30-bit word
    176     // to maintain parity bits between consecutive inputs. 
    177    
     176    // to maintain parity bits between consecutive inputs.
     177
    178178    ThirtyBitWord  W;
    179179
    180180    // Two 30-bit words make up the header of an RTCM2 message
    181     // (parity corrected) 
    182    
     181    // (parity corrected)
     182
    183183    unsigned int  H1;
    184184    unsigned int  H2;
     
    187187
    188188    std::vector<unsigned int> DW;
    189    
    190 }; 
     189
     190};
    191191
    192192
     
    202202
    203203class RTCM2_03 {
    204  
     204
    205205  public:
    206206    // Constructor
    207     RTCM2_03();
    208 
     207    RTCM2_03() {
     208      validMsg = false;
     209      x = 0.0;
     210      y = 0.0;
     211      z = 0.0;
     212    }
    209213    void extract(const RTCM2packet& P);
    210 
    211   public:
    212 
    213214    bool    validMsg;          // Validity flag
    214215    double  x,y,z;             // Station coordinates
     
    230231
    231232  public:
    232 
     233    RTCM2_23 () {
     234      validMsg = false;
     235    }
    233236    void extract(const RTCM2packet& P);
    234 
    235   public:
    236 
    237237    bool         validMsg;        // Validity flag
    238238    std::string  antType;         // Antenna descriptor
     
    248248// Purpose:
    249249//
    250 //   A class for handling RTCM 2 Reference Station Antenna 
     250//   A class for handling RTCM 2 Reference Station Antenna
    251251//   Reference Point Parameter messages
    252252//
     
    256256
    257257  public:
    258 
     258    RTCM2_24 () {
     259      validMsg  = false;
     260      isGPS     = false;
     261      isGLONASS = false;
     262      x         = 0.0;
     263      y         = 0.0;
     264      z         = 0.0;
     265      h         = 0.0;
     266    }
    259267    void extract(const RTCM2packet& P);
    260 
    261   public:
    262 
    263268    bool    validMsg;          // Validity flag
    264269    bool    isGPS;             // Flag for GPS supporting station
     
    277282// Purpose:
    278283//
    279 //   A class for handling blocks of RTCM2 18 & 19 packets that need to be 
     284//   A class for handling blocks of RTCM2 18 & 19 packets that need to be
    280285//   combined to get a complete set of measurements
    281286//
     
    284289class RTCM2_Obs {
    285290
    286   public: 
     291  public:
    287292
    288293    RTCM2_Obs();                           // Constructor
    289    
     294
    290295    void   extract(const RTCM2packet& P);  // Packet handler
    291296    void   clear();                        // Initialization
    292     bool   valid() const;                  // Check for complete obs block 
     297    bool   valid() const;                  // Check for complete obs block
    293298
    294299    double resolvedPhase_L1(int i) const;  // L1 & L2 carrier phase of i-th sat
    295     double resolvedPhase_L2(int i) const;  // with resolved 2^24 cy ambiguity 
     300    double resolvedPhase_L2(int i) const;  // with resolved 2^24 cy ambiguity
    296301                                           // (based on rng_C1)
    297302
     
    300305                         int&    epochWeek,
    301306                         double& epochSecs  ) const;
    302    
    303                                                
    304   public: 
     307
     308
     309  public:
    305310
    306311    double               secs;             // Seconds of hour (GPS time)
     
    325330
    326331    typedef std::bitset<8> msgflags;
    327    
     332
    328333    msgflags             availability;      // Msg availability flags
    329334    bool                 GPSonly;           // Flag for GPS-only station
    330335
    331 }; 
     336};
    332337
    333338
  • trunk/BNC/src/RTCM/RTCM2_2021.cpp

    r2588 r7629  
    1010const double ZEROVALUE = 1e-100;
    1111
    12 RTCM2_2021::RTCM2_2021() { }
    13 
    1412
    1513void RTCM2_2021::extract(const RTCM2packet& P) {
     
    1816  }
    1917
    20   // Error: at least 4 data words 
     18  // Error: at least 4 data words
    2119  if ( P.nDataWords()<5 ) {
    2220#if ( DEBUG > 0 )
     
    2624    return;
    2725  };
    28  
     26
    2927  // Error: number of data words has to be odd number
    3028  if ( P.nDataWords()%2==0 ){
     
    3634  };
    3735
    38   // Current epoch (mod 3600 sec) 
    39   double tt = 0.6*P.modZCount() 
     36  // Current epoch (mod 3600 sec)
     37  double tt = 0.6*P.modZCount()
    4038            + P.getUnsignedBits(4,20)*1.0e-6;
    4139
     
    5957  double multipleMsgInd = true;
    6058  for (unsigned iSat = 0; iSat < nSat; iSat++) {
    61     bool     multInd   =   P.getBits        (iSat*48 + 24, 1); 
     59    bool     multInd   =   P.getBits        (iSat*48 + 24, 1);
    6260    bool     isGPS     = ( P.getUnsignedBits(iSat*48 + 26, 1)==0 );
    6361    unsigned PRN       =   P.getUnsignedBits(iSat*48 + 27, 5);
     
    7169      PRN = 32;
    7270    }
    73    
     71
    7472    HiResCorr* corr = 0;
    7573    if ( !(corr = find_i(PRN)) ) {
     
    8078      data[PRN] = corr;
    8179    }
    82    
     80
    8381    corr->PRN = PRN;
    8482    corr->tt  = tt_;
     
    106104    // Message number 21
    107105    else if ( P.ID() == 21 ) {
    108       bool   P_CA_Ind  =   P.getBits        (iSat*48 + 25, 1); 
     106      bool   P_CA_Ind  =   P.getBits        (iSat*48 + 25, 1);
    109107      double dcorrUnit = ( P.getUnsignedBits(iSat*48 + 32, 1) ? 0.032 : 0.002);
    110108      double  corrUnit = ( P.getUnsignedBits(iSat*48 + 36, 1) ? 0.320 : 0.020);
     
    127125    }
    128126  }
    129  
     127
    130128  valid_ = !multipleMsgInd;
    131129}
     
    146144  tt_    = 0;
    147145  valid_ = false;
    148   for (map<unsigned, HiResCorr>::iterator 
     146  for (map<unsigned, HiResCorr>::iterator
    149147         ii = data_i_.begin(); ii != data_i_.end(); ii++) {
    150148    ii->second.reset();
     
    155153
    156154RTCM2_2021::HiResCorr::HiResCorr() :
    157   PRN(0), tt(0), 
     155  PRN(0), tt(0),
    158156  phase1 (0),     phase2 (2),
    159157  lock1  (0),     lock2  (0),
     
    163161  drange1(0),     drange2(0),
    164162  Pind1  (false), Pind2  (false),
    165   IODr1  (0),     IODr2  (0) { 
     163  IODr1  (0),     IODr2  (0) {
    166164}
    167165
  • trunk/BNC/src/RTCM/RTCM2_2021.h

    r7628 r7629  
    88
    99  public:
    10 
    11     RTCM2_2021();                           // Constructor
     10    RTCM2_2021() {// Constructor
     11      tt_    = 0.0;
     12      valid_ = false;
     13    }
    1214
    1315    void   extract(const RTCM2packet& P);  // Packet handler
     
    1820    double resolvedPhase_L2(int i) const;  // with resolved 2^24 cy ambiguity
    1921                                           // (based on rng_C1)
    20 
    21   public:
    2222
    2323    struct HiResCorr {
Note: See TracChangeset for help on using the changeset viewer.