Changeset 1044 in ntrip


Ignore:
Timestamp:
Aug 19, 2008, 11:36:54 AM (16 years ago)
Author:
zdenek
Message:

Zdenek Lukes: a) added logic for RTCM 2.3 messages 20/21 decoding

b) added logic for cycle slip flags (slip counters or lock time indicators) handling

Location:
trunk/BNC
Files:
15 edited

Legend:

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

    r1035 r1044  
    3434class t_obsInternal {
    3535 public:
     36
     37  t_obsInternal() :
     38    flags(0),
     39    satSys(' '),
     40    satNum(0),
     41    slot(0),
     42    GPSWeek(0),
     43    GPSWeeks(0.0),
     44    C1(0.0),
     45    C2(0.0),
     46    P1(0.0),
     47    P2(0.0),
     48    L1(0.0),
     49    L2(0.0),
     50    slip_cnt_L1(-1),
     51    slip_cnt_L2(-1),
     52    lock_timei_L1(-1),
     53    lock_timei_L2(-1),
     54    S1(0.0),
     55    S2(0.0),
     56    SNR1(0),
     57    SNR2(0) {
     58    StatID[0] = '\x0';
     59  }
    3660  int    flags;
    37   char   StatID[20+1];// Station ID
    38   char   satSys;      // Satellite System ('G' or 'R')
    39   int    satNum;      // Satellite Number (PRN for GPS NAVSTAR)
    40   int    slot;        // Slot Number (for Glonass)
    41   int    GPSWeek;     // Week of GPS-Time
    42   double GPSWeeks;    // Second of Week (GPS-Time)
    43   double C1;          // CA-code pseudorange (meters)
    44   double C2;          // CA-code pseudorange (meters)
    45   double P1;          // P1-code pseudorange (meters)
    46   double P2;          // P2-code pseudorange (meters)
    47   double L1;          // L1 carrier phase (cycles)
    48   double L2;          // L2 carrier phase (cycles)
    49   double S1;          // L1 signal-to noise ratio
    50   double S2;          // L2 signal-to noise ratio
    51   int    SNR1;        // L1 signal-to noise ratio (mapped to integer)
    52   int    SNR2;        // L2 signal-to noise ratio (mapped to integer)
     61  char   StatID[20+1];  // Station ID
     62  char   satSys;        // Satellite System ('G' or 'R')
     63  int    satNum;        // Satellite Number (PRN for GPS NAVSTAR)
     64  int    slot;          // Slot Number (for Glonass)
     65  int    GPSWeek;       // Week of GPS-Time
     66  double GPSWeeks;      // Second of Week (GPS-Time)
     67  double C1;            // CA-code pseudorange (meters)
     68  double C2;            // CA-code pseudorange (meters)
     69  double P1;            // P1-code pseudorange (meters)
     70  double P2;            // P2-code pseudorange (meters)
     71  double L1;            // L1 carrier phase (cycles)
     72  double L2;            // L2 carrier phase (cycles)
     73  int    slip_cnt_L1;   // L1 cumulative loss of continuity indicator (negative value = undefined)
     74  int    slip_cnt_L2;   // L2 cumulative loss of continuity indicator (negative value = undefined)
     75  int    lock_timei_L1; // L1 last lock time indicator                (negative value = undefined)
     76  int    lock_timei_L2; // L2 last lock time indicator                (negative value = undefined)
     77  double S1;            // L1 signal-to noise ratio
     78  double S2;            // L2 signal-to noise ratio
     79  int    SNR1;          // L1 signal-to noise ratio (mapped to integer)
     80  int    SNR2;          // L2 signal-to noise ratio (mapped to integer)
    5381};
    5482
     
    6088    _status = initial;
    6189
    62     _o.flags     = 0;
    63     _o.StatID[0] = '\0';
    64     _o.satSys    = 'G';
    65     _o.satNum    = 0;
    66     _o.slot      = 0;
    67     _o.GPSWeek   = 0;
    68     _o.GPSWeeks  = 0.0;
    69     _o.C1        = 0.0;
    70     _o.C2        = 0.0;
    71     _o.P1        = 0.0;
    72     _o.P2        = 0.0;
    73     _o.L1        = 0.0;
    74     _o.L2        = 0.0;
    75     _o.S1        = 0.0;
    76     _o.S2        = 0.0;
    77     _o.SNR1      = 0;
    78     _o.SNR2      = 0;
     90    _o.flags         = 0;
     91    _o.StatID[0]     = '\0';
     92    _o.satSys        = 'G';
     93    _o.satNum        = 0;
     94    _o.slot          = 0;
     95    _o.GPSWeek       = 0;
     96    _o.GPSWeeks      = 0.0;
     97    _o.C1            = 0.0;
     98    _o.C2            = 0.0;
     99    _o.P1            = 0.0;
     100    _o.P2            = 0.0;
     101    _o.L1            = 0.0;
     102    _o.L2            = 0.0;
     103    _o.S1            = 0.0;
     104    _o.S2            = 0.0;
     105    _o.slip_cnt_L1   = -1;
     106    _o.slip_cnt_L2   = -1;
     107    _o.lock_timei_L1 = -1;
     108    _o.lock_timei_L2 = -1;
     109    _o.SNR1          = 0;
     110    _o.SNR2          = 0;
    79111  }
    80112
  • trunk/BNC/RTCM/RTCM2.cpp

    r1029 r1044  
    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
    947949 
    948950  availability.reset();    // Message status flags
     
    10051007  bool    isGPS,isCAcode,isL1,isOth;
    10061008  int     NSat,idx;
    1007   int     sid,prn;
     1009  int     sid,prn,slip_cnt;
    10081010  double  t,rng,cph;
    10091011
     
    11141116     
    11151117      prn = (isGPS? sid : sid+200 );
    1116      
     1118
    11171119      // Carrier phase measurement (mod 2^23 [cy]; sign matched to range)
    11181120      cph = -P.getBits(iSat*48+40,32)/256.0;
     1121
     1122      // Slip counter
     1123      slip_cnt = P.getUnsignedBits(iSat*48+35,5);
    11191124
    11201125      // Is this a new PRN?
     
    11321137        cph_L1.push_back(0.0);
    11331138        cph_L2.push_back(0.0);
     1139        slip_L1.push_back(-1);
     1140        slip_L2.push_back(-1);
    11341141      };
    11351142     
    11361143      // Store measurement
    11371144      if (isL1) {
    1138         cph_L1[idx] = cph;
     1145        cph_L1 [idx] = cph;
     1146        slip_L1[idx] = slip_cnt;
    11391147      }
    11401148      else {
    1141         cph_L2[idx] = cph;
     1149        cph_L2 [idx] = cph;
     1150        slip_L2[idx] = slip_cnt;
    11421151      };
    11431152           
     
    12511260        cph_L1.push_back(0.0);
    12521261        cph_L2.push_back(0.0);
     1262        slip_L1.push_back(-1);
     1263        slip_L2.push_back(-1);
    12531264      };
    12541265     
     
    13391350
    13401351}; // End of namespace rtcm2
     1352
     1353
     1354
  • trunk/BNC/RTCM/RTCM2.h

    r1029 r1044  
    201201
    202202class RTCM2_03 {
    203 
    204   public:
    205 
    206     void extract(const RTCM2packet& P);
    207 
    208   public:
    209 
    210     bool    validMsg;          // Validity flag
    211     double  x,y,z;             // Station coordinates
    212 
     203 public:
     204 
     205  RTCM2_03() : validMsg(false), x(0.0), y(0.0), z(0.0) { }
     206 
     207  void extract(const RTCM2packet& P);
     208 
     209 public:
     210  bool    validMsg;          // Validity flag
     211  double  x,y,z;             // Station coordinates
    213212};
    214213
     
    309308    std::vector<double>  cph_L1;           // Carrier phase on L1 [cy]
    310309    std::vector<double>  cph_L2;           // Carrier phase on L2 [cy]
     310    std::vector<int>     slip_L1;          // Carrier phase slip counter, L1
     311    std::vector<int>     slip_L2;          // Carrier phase slip counter, L1
    311312
    312313  private:
  • trunk/BNC/RTCM/RTCM2Decoder.cpp

    r1029 r1044  
    3939 * -----------------------------------------------------------------------*/
    4040
     41#include <math.h>
     42#include <sstream>
     43#include <iomanip>
     44
    4145#include "../bncutils.h"
     46#include "rtcm_utils.h"
    4247#include "GPSDecoder.h"
    4348#include "RTCM2Decoder.h"
    4449
    4550using namespace std;
     51using namespace rtcm2;
    4652
    4753//
     
    4955//
    5056
    51 RTCM2Decoder::RTCM2Decoder() {
    52 
     57RTCM2Decoder::RTCM2Decoder(const std::string& ID) {
     58  _ID = ID;
    5359}
    5460
     
    5864
    5965RTCM2Decoder::~RTCM2Decoder() {
    60 }
    61 
    62 //
    63 
     66  for (t_pairMap::iterator ii = _ephPair.begin(); ii != _ephPair.end(); ii++) {
     67    delete ii->second;
     68  }
     69}
     70
     71
     72//
     73t_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//
    6487t_irc RTCM2Decoder::Decode(char* buffer, int bufLen) {
    6588
     
    95118          _obsList.push_back(obs);
    96119          if (_ObsBlock.PRN[iSat] > 100) {
    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);
     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];
     136          obs->_o.lock_timei_L1 = -1;
     137          obs->_o.lock_timei_L2 = -1;
    111138        }
    112139        _ObsBlock.clear();
    113140      }
    114141    }
     142
     143    else if ( _PP.ID() == 20 || _PP.ID() == 21 ) {
     144      _msg2021.extract(_PP);
     145
     146      if (_msg2021.valid()) {
     147        translateCorr2Obs();
     148      }
     149    }
     150
     151    else if ( _PP.ID() == 3 ) {
     152      _msg03.extract(_PP);
     153    }
     154
     155    else if ( _PP.ID() == 22 ) {
     156      _msg22.extract(_PP);
     157    }
    115158  }
    116159  return success;
    117160}
    118161
     162
     163
     164void RTCM2Decoder::storeEph(const gpsephemeris& gpseph) {
     165  t_ephGPS eph; eph.set(&gpseph);
     166
     167  storeEph(eph);
     168}
     169
     170
     171void RTCM2Decoder::storeEph(const t_ephGPS& gpseph) {
     172  t_ephGPS* eph = new t_ephGPS(gpseph);
     173
     174  string prn = eph->prn();
     175
     176  t_pairMap::iterator ip = _ephPair.find(prn);
     177  if (ip == _ephPair.end() ) {
     178    ip = _ephPair.insert(pair<string, t_ephPair*>(prn, new t_ephPair)).first;
     179  }
     180  t_ephPair* pair = ip->second;
     181
     182  if ( !pair->eph || eph->isNewerThan(pair->eph) ) {
     183    delete pair->oldEph;
     184    pair->oldEph = pair->eph;
     185    pair->eph    = eph;
     186
     187    return;
     188  }
     189
     190  delete eph;
     191}
     192 
     193 
     194void RTCM2Decoder::translateCorr2Obs() {
     195
     196  if ( !_msg03.validMsg || !_msg2021.valid() ) {
     197    return;
     198  }
     199
     200  double stax = _msg03.x + (_msg22.validMsg ? _msg22.dL1[0] : 0.0);
     201  double stay = _msg03.y + (_msg22.validMsg ? _msg22.dL1[1] : 0.0);
     202  double staz = _msg03.z + (_msg22.validMsg ? _msg22.dL1[2] : 0.0);
     203
     204  int    refWeek;
     205  double refSecs;
     206  currentGPSWeeks(refWeek, refSecs);
     207
     208  // Resolve receiver time of measurement (see RTCM 2.3, page 4-42, Message 18, Note 1)
     209  // ----------------------------------------------------------------------------------
     210  double hoursec_est  = _msg2021.hoursec();              // estimated time of measurement
     211  double hoursec_rcv  = rint(hoursec_est * 1e2) / 1e2;   // receiver clock reading at hoursec_est 
     212  double rcv_clk_bias = (hoursec_est - hoursec_rcv) * c_light;
     213
     214  int    GPSWeek;
     215  double GPSWeeks;
     216  resolveEpoch(hoursec_est, refWeek, refSecs,
     217               GPSWeek, GPSWeeks);
     218
     219  int    GPSWeek_rcv;
     220  double GPSWeeks_rcv;
     221  resolveEpoch(hoursec_rcv, refWeek, refSecs,
     222               GPSWeek_rcv, GPSWeeks_rcv);
     223
     224  // Loop over all satellites
     225  // ------------------------
     226  for (RTCM2_2021::data_iterator icorr = _msg2021.data.begin();
     227       icorr != _msg2021.data.end(); icorr++) {
     228    const RTCM2_2021::HiResCorr* corr = icorr->second;
     229
     230    ostringstream oPRN; oPRN.fill('0');
     231
     232    oPRN <<            (corr->PRN < 200 ? 'G'       : 'R')
     233         << setw(2) << (corr->PRN < 200 ? corr->PRN : corr->PRN - 200);
     234
     235    string PRN(oPRN.str());
     236
     237    t_pairMap::const_iterator ieph = _ephPair.find(PRN);
     238    const t_eph* eph0 = 0;
     239    const t_eph* eph1 = 0;
     240
     241    if ( ieph != _ephPair.end() ) {
     242      eph0 = ieph->second->eph;
     243      eph1 = ieph->second->oldEph;
     244    }
     245
     246    if ( !eph0 && !eph1 ) {
     247      continue;
     248    }
     249
     250    double L1 = 0;
     251    double L2 = 0;
     252    double P1 = 0;
     253    double P2 = 0;
     254    string obsT = "";
     255
     256    // new observation
     257    p_obs new_obs = 0;
     258
     259    for (unsigned ii = 0; ii < 4; ii++) {
     260      int          IODcorr = 0;
     261      double       corrVal = 0;
     262      const t_eph* eph     = 0;
     263      double*      obsVal  = 0;
     264
     265      switch (ii) {
     266      case 0: // --- L1 ---
     267        IODcorr = corr->IODp1;
     268        corrVal = corr->phase1 * LAMBDA_1;
     269        obsVal  = &L1;
     270        obsT    = "L1";
     271        break;
     272      case 1: // --- L2 ---
     273        IODcorr = corr->IODp2;
     274        corrVal = corr->phase2 * LAMBDA_2;
     275        obsVal  = &L2;
     276        obsT    = "L2";
     277        break;
     278      case 2: // --- P1 ---
     279        IODcorr = corr->IODr1;
     280        corrVal = corr->range1;
     281        obsVal  = &P1;
     282        obsT    = "P1";
     283        break;
     284      case 3: // --- P2 ---
     285        IODcorr = corr->IODr2;
     286        corrVal = corr->range2;
     287        obsVal  = &P2;
     288        obsT    = "P2";
     289        break;
     290      default:
     291        continue;
     292      }
     293
     294      eph = 0;
     295      if      ( eph0 && eph0->IOD() == IODcorr )
     296        eph = eph0;
     297      else if ( eph1 && eph1->IOD() == IODcorr )
     298        eph = eph1;
     299      if ( eph && corr ) {
     300        int    GPSWeek_tot;
     301        double GPSWeeks_tot;
     302        double rho, xSat, ySat, zSat, clkSat;
     303        cmpRho(eph, stax, stay, staz,
     304               GPSWeek, GPSWeeks,
     305               rho, GPSWeek_tot, GPSWeeks_tot,
     306               xSat, ySat, zSat, clkSat);
     307
     308        *obsVal = rho - corrVal + rcv_clk_bias - clkSat;
     309
     310        if ( *obsVal == 0 )  *obsVal = ZEROVALUE;
     311
     312        // Allocate new memory
     313        // -------------------
     314        if ( !new_obs ) {
     315          new_obs = new t_obs();
     316
     317          new_obs->_o.StatID[0] = '\x0';
     318          new_obs->_o.satSys    = (corr->PRN < 200 ? 'G'       : 'R');
     319          new_obs->_o.satNum    = (corr->PRN < 200 ? corr->PRN : corr->PRN - 200);
     320         
     321          new_obs->_o.GPSWeek   = GPSWeek_rcv;
     322          new_obs->_o.GPSWeeks  = GPSWeeks_rcv;
     323        }
     324       
     325        // Store estimated measurements
     326        // ----------------------------
     327        switch (ii) {
     328        case 0: // --- L1 ---
     329          new_obs->_o.L1 = *obsVal / LAMBDA_1;
     330          new_obs->_o.slip_cnt_L1   = corr->lock1;
     331          new_obs->_o.lock_timei_L1 = -1;
     332          break;
     333        case 1: // --- L2 ---
     334          new_obs->_o.L2 = *obsVal / LAMBDA_2;
     335          new_obs->_o.slip_cnt_L2   = corr->lock2;
     336          new_obs->_o.lock_timei_L2 = -1;
     337          break;
     338        case 2: // --- C1 / P1 ---
     339          if ( corr->Pind1 )
     340            new_obs->_o.P1 = *obsVal;
     341          else
     342            new_obs->_o.C1 = *obsVal;
     343          break;
     344        case 3: // --- C2 / P2 ---
     345          if ( corr->Pind2 )
     346            new_obs->_o.P2 = *obsVal;
     347          else
     348            new_obs->_o.C2 = *obsVal;
     349          break;
     350        default:
     351          continue;
     352        }
     353      }
     354    } // loop over frequencies
     355   
     356    if ( new_obs ) {
     357      _obsList.push_back( new_obs );
     358    }
     359  }
     360}
  • trunk/BNC/RTCM/RTCM2Decoder.h

    r1029 r1044  
    2626#define INC_RTCM2DECODER_H
    2727
     28#include <map>
     29
    2830#include "GPSDecoder.h"
    2931#include "RTCM2.h"
     32#include "RTCM2_2021.h"
     33#include "../RTCM3/rtcm3torinex.h"
     34#include "../RTCM3/ephemeris.h"
    3035
    3136class RTCM2Decoder: public GPSDecoder {
    3237
    3338  public:
    34     RTCM2Decoder();
     39    RTCM2Decoder(const std::string& ID);
    3540    virtual ~RTCM2Decoder();
    3641    virtual t_irc Decode(char* buffer, int bufLen);
    3742
     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
     50    std::string ID() const { return _ID; }
     51
    3852  private:
    3953
    40     std::string        _buffer;
    41     rtcm2::RTCM2_Obs   _ObsBlock;
    42     rtcm2::RTCM2packet _PP;
     54    class t_ephPair {
     55    public:
     56      t_ephPair() {
     57        eph    = 0;
     58        oldEph = 0;
     59      }
     60     
     61      ~t_ephPair() {
     62        delete eph;
     63        delete oldEph;
     64      }
     65     
     66      t_eph* eph;
     67      t_eph* oldEph;
     68    };
    4369
     70    void translateCorr2Obs();
     71
     72    std::string            _ID;
     73
     74    std::string            _buffer;
     75    rtcm2::RTCM2packet     _PP;
     76
     77    // for messages 18, 19 decoding
     78    rtcm2::RTCM2_Obs       _ObsBlock;
     79
     80    // for messages 20, 21 decoding
     81    rtcm2::RTCM2_03           _msg03;
     82    rtcm2::RTCM2_22           _msg22;
     83    rtcm2::RTCM2_2021         _msg2021;
     84    std::map<std::string, t_ephPair*> _ephPair;
     85
     86    typedef std::map<std::string, t_ephPair*> t_pairMap;
    4487};
    4588
  • trunk/BNC/RTCM/rtcm_utils.cpp

    r1027 r1044  
    3838  eph->position(GPSWeek, GPSWeeks, xSat, ySat, zSat, clkSat);
    3939
    40   cout << "----- cmpRho -----\n";
    41   eph->print(cout);
    42   cout << "  pos " << setw(4)  << GPSWeek
    43        << " "      << setw(14) << setprecision(6) << GPSWeeks
    44        << " "      << setw(13) << setprecision(3) << xSat
    45        << " "      << setw(13) << setprecision(3) << ySat
    46        << " "      << setw(13) << setprecision(3) << zSat
    47        << endl;
     40  ////cout << "----- cmpRho -----\n";
     41  ////eph->print(cout);
     42  ////cout << "  pos " << setw(4)  << GPSWeek
     43  ////     << " "      << setw(14) << setprecision(6) << GPSWeeks
     44  ////     << " "      << setw(13) << setprecision(3) << xSat
     45  ////     << " "      << setw(13) << setprecision(3) << ySat
     46  ////     << " "      << setw(13) << setprecision(3) << zSat
     47  ////     << endl;
    4848
    4949  // Loop until the correct Time Of Transmission is found
     
    8585    rho = sqrt(dx*dx + dy*dy + dz*dz);
    8686
    87     cout << "  scrd "   << setw(4)  << GPSWeek_tot
    88          << " "         << setw(15) << setprecision(8) << GPSWeeks_tot
    89          << " "         << setw(13) << setprecision(3) << xSat
    90          << " "         << setw(13) << setprecision(3) << ySat
    91          << " "         << setw(13) << setprecision(3) << zSat
    92          << " rcv0 "    << setw(12) << setprecision(3) << stax
    93          << " "         << setw(12) << setprecision(3) << stay
    94          << " "         << setw(12) << setprecision(3) << staz
    95          << " rcv  "    << setw(12) << setprecision(3) << xRec
    96          << " "         << setw(12) << setprecision(3) << yRec
    97          << " "         << setw(12) << setprecision(3) << zRec
    98          << " dPhi "    << scientific << setw(13) << setprecision(10) << dPhi  << fixed
    99          << " rho "     << setw(13) << setprecision(3) << rho
    100          << endl;
     87    ////cout << "  scrd "   << setw(4)  << GPSWeek_tot
     88    ////         << " "         << setw(15) << setprecision(8) << GPSWeeks_tot
     89    ////         << " "         << setw(13) << setprecision(3) << xSat
     90    ////         << " "         << setw(13) << setprecision(3) << ySat
     91    ////         << " "         << setw(13) << setprecision(3) << zSat
     92    ////         << " rcv0 "    << setw(12) << setprecision(3) << stax
     93    ////         << " "         << setw(12) << setprecision(3) << stay
     94    ////         << " "         << setw(12) << setprecision(3) << staz
     95    ////         << " rcv  "    << setw(12) << setprecision(3) << xRec
     96    ////         << " "         << setw(12) << setprecision(3) << yRec
     97    ////         << " "         << setw(12) << setprecision(3) << zRec
     98    ////         << " dPhi "    << scientific << setw(13) << setprecision(10) << dPhi  << fixed
     99    ////         << " rho "     << setw(13) << setprecision(3) << rho
     100    ////         << endl;
    101101   
    102102
     
    112112  clkSat *= c_light;  // satellite clock correction in meters
    113113
    114   cout << "***** cmpRho *****\n";
    115 
    116114  return 0;
    117115}
  • trunk/BNC/RTCM3/RTCM3Decoder.cpp

    r1035 r1044  
    224224                else
    225225                {
     226                  int isat = (_Parser.Data.satellites[ii] < 120
     227                              ? _Parser.Data.satellites[ii]
     228                              : _Parser.Data.satellites[ii] - 80);
     229                 
    226230                  // variables df and pos are used consequently. Perlt
    227231                  if      (df & GNSSDF_C1DATA) {
     
    238242                  }
    239243                  else if (df & (GNSSDF_L1CDATA|GNSSDF_L1PDATA)) {
    240                     obs->_o.L1   = _Parser.Data.measdata[ii][pos];
    241                     obs->_o.SNR1 = _Parser.Data.snrL1[ii];
     244                    obs->_o.L1            = _Parser.Data.measdata[ii][pos];
     245                    obs->_o.SNR1          = _Parser.Data.snrL1[ii];
     246                    obs->_o.lock_timei_L1 = _Parser.lastlockl1[isat];
    242247                  }
    243248                  else if (df & (GNSSDF_L2CDATA|GNSSDF_L2PDATA)) {
    244                     obs->_o.L2   = _Parser.Data.measdata[ii][pos];
    245                     obs->_o.SNR2 = _Parser.Data.snrL2[ii];
     249                    obs->_o.L2            = _Parser.Data.measdata[ii][pos];
     250                    obs->_o.SNR2          = _Parser.Data.snrL2[ii];
     251                    obs->_o.lock_timei_L2 = _Parser.lastlockl2[isat];
    246252                  }
    247253                  else if (df & (GNSSDF_S1CDATA|GNSSDF_S1PDATA)) {
  • trunk/BNC/bnc.pro

    r1029 r1044  
    33# -----------------------------
    44CONFIG += release
    5 ###CONFIG -= debug
     5###CONFIG += debug
    66
    77DEFINES += NO_RTCM3_MAIN
     
    2727          bncconst.h bnchtml.h bnctableitem.h bnczerodecoder.h        \
    2828          RTCM/GPSDecoder.h RTCM/RTCM2.h RTCM/RTCM2Decoder.h          \
     29          RTCM/RTCM2_2021.h RTCM/rtcm_utils.h                         \
    2930          RTCM3/RTCM3Decoder.h RTCM3/rtcm3torinex.h                   \
    3031          RTCM3/RTCM3coDecoder.h RTCM3/clock_orbit_rtcm.h             \
     32          RTCM3/ephemeris.h RTCM3/timeutils.h                         \
    3133          RTIGS/RTIGSDecoder.h RTIGS/rtigs_records.h                  \
    3234          RTIGS/cgps_transform.h RTIGS/rtstruct.h RTIGS/rtacp.h RTIGS/gpswro.h
     
    3739          bnczerodecoder.cpp                                          \
    3840          RTCM/RTCM2.cpp RTCM/RTCM2Decoder.cpp                        \
     41          RTCM/RTCM2_2021.cpp RTCM/rtcm_utils.cpp                     \
    3942          RTCM3/RTCM3Decoder.cpp RTCM3/rtcm3torinex.c                 \
    4043          RTCM3/RTCM3coDecoder.cpp RTCM3/clock_orbit_rtcm.c           \
     44          RTCM3/ephemeris.cpp RTCM3/timeutils.cpp                     \
    4145          RTIGS/RTIGSDecoder.cpp RTIGS/cgps_transform.cpp
    4246
  • trunk/BNC/bncapp.cpp

    r1035 r1044  
    192192  QMutexLocker locker(&_mutex);
    193193
     194  gpsephemeris copy_gpseph = *gpseph;
     195  emit newEphGPS(copy_gpseph);
     196
    194197  printEphHeader();
    195198
  • trunk/BNC/bncapp.h

    r1029 r1044  
    4949    void slotQuit();
    5050
    51  signals:
    52    void newMessage(QByteArray msg);
     51  signals:
     52    void newMessage(QByteArray msg);
     53    void newEphGPS(gpsephemeris gpseph);
    5354   
    5455 private slots:
  • trunk/BNC/bncgetthread.cpp

    r1035 r1044  
    4040
    4141#include <stdlib.h>
     42#include <iomanip>
    4243
    4344#include <QFile>
     
    144145    _rnx = new bncRinex(_staID, mountPoint, format, latitude, longitude, nmea);
    145146  }
     147  _rnx_set_position = false;
    146148
    147149  msleep(100); //sleep 0.1 sec
     
    160162  }
    161163  delete _decoder;
    162   delete _rnx;   
     164  delete _rnx;
    163165}
    164166
     
    369371    if      (_format.indexOf("RTCM_2") != -1) {
    370372      emit(newMessage("Get Data: " + _staID + " in RTCM 2.x format"));
    371       _decoder = new RTCM2Decoder();
     373      _decoder = new RTCM2Decoder(_staID.data());
    372374    }
    373375    else if (_format.indexOf("RTCM_3") != -1) {
     
    560562
    561563        delete [] data;
    562        
     564
    563565        QListIterator<p_obs> it(_decoder->_obsList);
    564566        while (it.hasNext()) {
     
    648650          // ------------
    649651          if (_rnx) {
    650              long iSec    = long(floor(obs->_o.GPSWeeks+0.5));
    651              long newTime = obs->_o.GPSWeek * 7*24*3600 + iSec;
    652             if (_samplingRate == 0 || iSec % _samplingRate == 0) {
    653               _rnx->deepCopy(obs);
     652            bool dump = true;
     653
     654            ////RTCM2Decoder* decoder2 = dynamic_cast<RTCM2Decoder*>(_decoder);
     655            ////if ( decoder2 && !_rnx_set_position ) {
     656            ////  double stax, stay, staz;
     657            ////  if ( decoder2->getStaCrd(stax, stay, staz) == success ) {
     658            ////        _rnx->setApproxPos(stax, stay, staz);
     659            ////        _rnx_set_position = true;
     660            ////  }
     661            ////  else {
     662            ////        dump = false;
     663            ////  }
     664            ////}
     665             
     666            if ( dump ) {
     667              long iSec    = long(floor(obs->_o.GPSWeeks+0.5));
     668              long newTime = obs->_o.GPSWeek * 7*24*3600 + iSec;
     669              if (_samplingRate == 0 || iSec % _samplingRate == 0) {
     670                _rnx->deepCopy(obs);
     671              }
     672              _rnx->dumpEpoch(newTime);
    654673            }
    655             _rnx->dumpEpoch(newTime);
    656           }
    657 
     674          }
     675
     676          // Emit new observation signal
     677          // ---------------------------
    658678          bool firstObs = (obs == _decoder->_obsList.first());
    659679          obs->_status = t_obs::posted;
     
    757777  }
    758778}
     779
     780//
     781//////////////////////////////////////////////////////////////////////////////
     782void bncGetThread::slotNewEphGPS(gpsephemeris gpseph) {
     783  RTCM2Decoder* decoder = dynamic_cast<RTCM2Decoder*>(_decoder);
     784
     785  if ( decoder ) {
     786    QMutexLocker locker(&_mutex);
     787 
     788    decoder->storeEph(gpseph);
     789  }
     790}
     791
  • trunk/BNC/bncgetthread.h

    r1030 r1044  
    3131
    3232#include "RTCM/GPSDecoder.h"
     33#include "RTCM3/rtcm3torinex.h"
    3334#include "bncconst.h"
    3435
     
    5657   void error(QByteArray staID);
    5758   void newMessage(QByteArray msg);
     59
     60 public slots:
     61   void slotNewEphGPS(gpsephemeris gpseph);
    5862
    5963 protected:
     
    96100   int         _samplingRate;
    97101   bncRinex*   _rnx;
     102   bool        _rnx_set_position;
    98103   QDateTime   _decodeFailure;
    99104   QDateTime   _decodeStart;
  • trunk/BNC/bncrinex.cpp

    r1029 r1044  
    9393    _rinexVers = 2;
    9494  }
     95
     96  _approxPos[0] = _approxPos[1] = _approxPos[2] = 0.0;
    9597}
    9698
     
    447449  // ------------------
    448450  else {
    449     double approxPos[3];  approxPos[0]  = approxPos[1]  = approxPos[2]  = 0.0;
    450451    double antennaNEU[3]; antennaNEU[0] = antennaNEU[1] = antennaNEU[2] = 0.0;
    451452   
     
    477478         << setw(20) << " "                                          << "ANT # / TYPE"         << endl;
    478479    _out.unsetf(ios::left);
    479     _out << setw(14) << setprecision(4) << approxPos[0]
    480          << setw(14) << setprecision(4) << approxPos[1]
    481          << setw(14) << setprecision(4) << approxPos[2]
     480    _out << setw(14) << setprecision(4) << _approxPos[0]
     481         << setw(14) << setprecision(4) << _approxPos[1]
     482         << setw(14) << setprecision(4) << _approxPos[2]
    482483         << "                  "                                     << "APPROX POSITION XYZ"  << endl;
    483484    _out << setw(14) << setprecision(4) << antennaNEU[0]
     
    565566  double sec = double(datTim.time().second()) + fmod(fObs->_o.GPSWeeks,1.0);
    566567
    567   // RINEX Version 3
    568   // ---------------
     568  // Epoch header line: RINEX Version 3
     569  // ----------------------------------
    569570  if (_rinexVers == 3) {
    570     char sbasflag = 'S';
    571571    _out << datTim.toString("> yyyy MM dd hh mm ").toAscii().data()
    572572         << setw(10) << setprecision(7) << sec
    573573         << "  " << 0 << setw(3)  << dumpList.size() << endl;
    574 
    575     QListIterator<p_obs> it(dumpList);
    576     while (it.hasNext()) {
    577       p_obs obs = it.next();
    578 // Changed data output, C1P, C2C|X, L2C|X, S2C|X added. Changed Output for SBAS Perlt 
    579       if (sbasflag != obs->_o.satSys) {
    580       _out << obs->_o.satSys
    581            << setw(2) << setfill('0') << obs->_o.satNum << setfill(' ')
    582            << setw(14) << setprecision(3) << obs->_o.C1 << "  " 
    583            << setw(14) << setprecision(3) << obs->_o.P1 << "  " 
    584            << setw(14) << setprecision(3) << obs->_o.L1 << " "
    585            << setw(1)                     << obs->_o.SNR1
    586            << setw(14) << setprecision(3) << obs->_o.S1 << "  "
    587            << setw(14) << setprecision(3) << obs->_o.C2 << "  " 
    588            << setw(14) << setprecision(3) << obs->_o.P2 << "  " ;
    589       if ((obs->_o.C2 != 0.0) && (obs->_o.P2 == 0.0)) {
    590        _out << setw(14) << setprecision(3) << obs->_o.L2 << " "
    591             << setw(1)                     << obs->_o.SNR2
    592             << setw(14) << setprecision(3) << obs->_o.S2 << "  "
    593             << "         0.000           0.000  ";
    594       }
    595       else {
    596        _out << "         0.000           0.000  "
    597             << setw(14) << setprecision(3) << obs->_o.L2 << " "
    598             << setw(1)                     << obs->_o.SNR2
    599             << setw(14) << setprecision(3) << obs->_o.S2;
    600       }
    601       _out << endl;
    602       }
    603       else {
    604       _out << obs->_o.satSys
    605            << setw(2) << setfill('0') << obs->_o.satNum << setfill(' ')
    606            << setw(14) << setprecision(3) << obs->_o.C1 << "  " 
    607            << setw(14) << setprecision(3) << obs->_o.P1 << "  " 
    608            << setw(14) << setprecision(3) << obs->_o.L1 << " "
    609            << setw(1)                     << obs->_o.SNR1
    610            << setw(14) << setprecision(3) << obs->_o.S1 << endl;
    611       }
    612       delete obs;
    613     }
    614   }
    615 
    616   // RINEX Version 2
    617   // ---------------
     574  }
     575  // Epoch header line: RINEX Version 2
     576  // ----------------------------------
    618577  else {
    619578    _out << datTim.toString(" yy MM dd hh mm ").toAscii().data()
    620579         << setw(10) << setprecision(7) << sec
    621580         << "  " << 0 << setw(3)  << dumpList.size();
    622    
     581
    623582    QListIterator<p_obs> it(dumpList); int iSat = 0;
    624583    while (it.hasNext()) {
     
    632591    }
    633592    _out << endl;
    634    
    635     it.toFront();
    636     while (it.hasNext()) {
    637       p_obs obs = it.next();
    638    
     593  }
     594
     595  QListIterator<p_obs> it(dumpList);
     596  while (it.hasNext()) {
     597    p_obs obs = it.next();
     598
     599    // Cycle slips detection
     600    // ---------------------
     601    int prn = 0;
     602    switch (obs->_o.satSys) {
     603    case 'G': prn = obs->_o.satNum;       break;
     604    case 'R': prn = obs->_o.satNum + 200; break;
     605    default:  prn = obs->_o.satNum;
     606    }
     607
     608    char lli1 = ' ';
     609    char lli2 = ' ';
     610    if      ( obs->_o.slip_cnt_L1 >= 0 ) {
     611      if ( _slip_cnt_L1.find(prn)         != _slip_cnt_L1.end() &&
     612           _slip_cnt_L1.find(prn).value() != obs->_o.slip_cnt_L1 ) {
     613        lli1 = '1';
     614      }
     615    }
     616    else if ( obs->_o.lock_timei_L1 >= 0 ) {
     617      if ( _lock_timei_L1.find(prn)         != _lock_timei_L1.end() &&
     618           _lock_timei_L1.find(prn).value() != obs->_o.lock_timei_L1 ) {
     619        lli1 = '1';
     620      }
     621    }
     622
     623    if ( obs->_o.slip_cnt_L2 >= 0 ) {
     624      if ( _slip_cnt_L2.find(prn)         != _slip_cnt_L2.end() &&
     625           _slip_cnt_L2.find(prn).value() != obs->_o.slip_cnt_L2 ) {
     626        lli2 = '1';
     627      }
     628    }
     629    else if ( obs->_o.lock_timei_L2 >= 0 ) {
     630      if ( _lock_timei_L2.find(prn)         != _lock_timei_L2.end() &&
     631           _lock_timei_L2.find(prn).value() != obs->_o.lock_timei_L2 ) {
     632        lli2 = '1';
     633      }
     634    }
     635
     636    _slip_cnt_L1[prn]   = obs->_o.slip_cnt_L1;
     637    _slip_cnt_L2[prn]   = obs->_o.slip_cnt_L2;
     638
     639    _lock_timei_L1[prn] = obs->_o.lock_timei_L1;
     640    _lock_timei_L2[prn] = obs->_o.lock_timei_L2;
     641
     642    // RINEX Version 3
     643    // ---------------
     644    if (_rinexVers == 3) {
     645      char sbasflag = 'S';
     646      // Changed data output, C1P, C2C|X, L2C|X, S2C|X added. Changed Output for SBAS Perlt 
     647      if (sbasflag != obs->_o.satSys) {
     648        _out << obs->_o.satSys
     649             << setw(2) << setfill('0') << obs->_o.satNum << setfill(' ')
     650             << setw(14) << setprecision(3) << obs->_o.C1 << "  " 
     651             << setw(14) << setprecision(3) << obs->_o.P1 << "  " 
     652             << setw(14) << setprecision(3) << obs->_o.L1 << lli1
     653             << setw(1)                     << obs->_o.SNR1
     654             << setw(14) << setprecision(3) << obs->_o.S1 << "  "
     655             << setw(14) << setprecision(3) << obs->_o.C2 << "  " 
     656             << setw(14) << setprecision(3) << obs->_o.P2 << "  " ;
     657        if ((obs->_o.C2 != 0.0) && (obs->_o.P2 == 0.0)) {
     658          _out << setw(14) << setprecision(3) << obs->_o.L2 << lli2
     659               << setw(1)                     << obs->_o.SNR2
     660               << setw(14) << setprecision(3) << obs->_o.S2 << "  "
     661               << "         0.000           0.000  ";
     662        }
     663        else {
     664          _out << "         0.000           0.000  "
     665               << setw(14) << setprecision(3) << obs->_o.L2 << " "
     666               << setw(1)                     << obs->_o.SNR2
     667               << setw(14) << setprecision(3) << obs->_o.S2;
     668        }
     669        _out << endl;
     670      }
     671      else {
     672        _out << obs->_o.satSys
     673             << setw(2) << setfill('0') << obs->_o.satNum << setfill(' ')
     674             << setw(14) << setprecision(3) << obs->_o.C1 << "  " 
     675             << setw(14) << setprecision(3) << obs->_o.P1 << "  " 
     676             << setw(14) << setprecision(3) << obs->_o.L1 << lli1
     677             << setw(1)                     << obs->_o.SNR1
     678             << setw(14) << setprecision(3) << obs->_o.S1 << endl;
     679      }
     680    }
     681
     682    // RINEX Version 2
     683    // ---------------
     684    else {
    639685      char lli = ' ';
    640686      char snr = ' ';
     
    643689      _out << setw(14) << setprecision(3) << obs->_o.P1 << lli << snr;
    644690      _out << setw(14) << setprecision(3) << obs->_o.P2 << lli << snr;
    645       _out << setw(14) << setprecision(3) << obs->_o.L1 << lli 
     691      _out << setw(14) << setprecision(3) << obs->_o.L1 << lli1
    646692           << setw(1) << obs->_o.SNR1 << endl;
    647       _out << setw(14) << setprecision(3) << obs->_o.L2 << lli
     693      _out << setw(14) << setprecision(3) << obs->_o.L2 << lli2
    648694           << setw(1) << obs->_o.SNR2;
    649695      _out << setw(14) << setprecision(3) << obs->_o.S1 ;
    650696      _out << setw(16) << setprecision(3) << obs->_o.S2 ;
    651697      _out << endl;
    652    
    653       delete obs;
    654     }
     698    }
     699
     700    delete obs;
    655701  }
    656702
  • trunk/BNC/bncrinex.h

    r1029 r1044  
    4949                               QDateTime* nextEpoch = 0);
    5050
     51   void setApproxPos(double stax, double stay, double staz) {
     52     _approxPos[0] = stax;
     53     _approxPos[1] = stay;
     54     _approxPos[2] = staz;
     55   }
     56
    5157 protected:
    5258   virtual void run() {};
     
    8187   bool          _reloadTable;
    8288   bool          _reloadDone;
     89   double        _approxPos[3];
     90
     91   QMap<int, int> _slip_cnt_L1;
     92   QMap<int, int> _slip_cnt_L2;
     93   QMap<int, int> _lock_timei_L1;
     94   QMap<int, int> _lock_timei_L2;
    8395};
    8496
  • trunk/BNC/bncwindow.cpp

    r1042 r1044  
    705705            SLOT(slotNewBytes(QByteArray, double)));
    706706
     707    connect(((bncApp*)qApp), SIGNAL(newEphGPS(gpsephemeris)),
     708            getThread, SLOT(slotNewEphGPS(gpsephemeris)));
     709
    707710    _caster->addGetThread(getThread);
    708711
Note: See TracChangeset for help on using the changeset viewer.