Changeset 2767 in ntrip for trunk/BNS


Ignore:
Timestamp:
Dec 12, 2010, 9:56:18 AM (13 years ago)
Author:
mervart
Message:
 
Location:
trunk/BNS
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNS/bns.cpp

    r2641 r2767  
    271271      emit(newOutEphBytes(size));
    272272    }
    273     ////    QByteArray buffer = "New Ephemeris " + ep->prn().toAscii() + "\n";
    274     ////    _casterEph->write(buffer.data(), buffer.length());
    275     ////    int len = buffer.length();
    276     ////    if (len > 0) {
    277     ////      emit(newOutEphBytes(len));
    278     ////    }
    279273  }
    280274
     
    419413      _caster.at(ic)->open();
    420414
    421       for (int oldEph = 0; oldEph <= 0; oldEph++) { // TODO: handle old ephemeris
     415      struct ClockOrbit co;
     416      memset(&co, 0, sizeof(co));
     417      co.GPSEpochTime      = (int)_GPSweeks;
     418      co.GLONASSEpochTime  = (int)fmod(_GPSweeks, 86400.0)
     419                           + 3 * 3600 - gnumleap(_year, _month, _day);
     420      co.ClockDataSupplied = 1;
     421      co.OrbitDataSupplied = 1;
     422      co.SatRefDatum       = DATUM_ITRF;
    422423     
    423         struct ClockOrbit co;
    424         memset(&co, 0, sizeof(co));
    425         co.GPSEpochTime      = (int)_GPSweeks;
    426         co.GLONASSEpochTime  = (int)fmod(_GPSweeks, 86400.0)
     424      struct Bias bias;
     425      memset(&bias, 0, sizeof(bias));
     426      bias.GPSEpochTime      = (int)_GPSweeks;
     427      bias.GLONASSEpochTime  = (int)fmod(_GPSweeks, 86400.0)
    427428                             + 3 * 3600 - gnumleap(_year, _month, _day);
    428         co.ClockDataSupplied = 1;
    429         co.OrbitDataSupplied = 1;
    430         co.SatRefDatum       = DATUM_ITRF;
     429
     430      for (int ii = 0; ii < lines.size(); ii++) {
     431
     432        QString      prn;
     433        ColumnVector xx(14); xx = 0.0;
     434        t_ephPair*   pair = 0;
    431435     
    432         struct Bias bias;
    433         memset(&bias, 0, sizeof(bias));
    434         bias.GPSEpochTime      = (int)_GPSweeks;
    435         bias.GLONASSEpochTime  = (int)fmod(_GPSweeks, 86400.0)
    436                                + 3 * 3600 - gnumleap(_year, _month, _day);
    437 
    438         for (int ii = 0; ii < lines.size(); ii++) {
    439 
    440           QString      prn;
    441           ColumnVector xx(14); xx = 0.0;
    442           t_eph*       ep = 0;
    443      
    444           if (oldEph == 0 && ic == 0) {
    445             QTextStream in(lines[ii].toAscii());
    446             in >> prn;
    447             prns << prn;
    448             if ( _ephList.contains(prn) ) {
    449               in >> xx(1) >> xx(2) >> xx(3) >> xx(4) >> xx(5)
    450                  >> xx(6) >> xx(7) >> xx(8) >> xx(9) >> xx(10)
    451                  >> xx(11) >> xx(12) >> xx(13) >> xx(14);
    452               xx(1) *= 1e3;          // x-crd
    453               xx(2) *= 1e3;          // y-crd
    454               xx(3) *= 1e3;          // z-crd
    455               xx(4) *= 1e-6;         // clk
    456               xx(5) *= 1e-6;         // rel. corr.
    457                                      // xx(6), xx(7), xx(8) ... PhaseCent - CoM
    458                                      // xx(9)  ... P1-C1 DCB in meters
    459                                      // xx(10) ... P1-P2 DCB in meters
    460                                      // xx(11) ... dT
    461               xx(12) *= 1e3;         // x-crd at time + dT
    462               xx(13) *= 1e3;         // y-crd at time + dT
    463               xx(14) *= 1e3;         // z-crd at time + dT
    464 
    465               t_ephPair* pair = _ephList[prn];
    466               pair->xx = xx;
    467               ep = pair->eph;
    468             }
     436        if (ic == 0) {
     437          QTextStream in(lines[ii].toAscii());
     438          in >> prn;
     439          prns << prn;
     440          if ( _ephList.contains(prn) ) {
     441            in >> xx(1) >> xx(2) >> xx(3) >> xx(4) >> xx(5)
     442               >> xx(6) >> xx(7) >> xx(8) >> xx(9) >> xx(10)
     443               >> xx(11) >> xx(12) >> xx(13) >> xx(14);
     444            xx(1) *= 1e3;          // x-crd
     445            xx(2) *= 1e3;          // y-crd
     446            xx(3) *= 1e3;          // z-crd
     447            xx(4) *= 1e-6;         // clk
     448            xx(5) *= 1e-6;         // rel. corr.
     449                                   // xx(6), xx(7), xx(8) ... PhaseCent - CoM
     450                                   // xx(9)  ... P1-C1 DCB in meters
     451                                   // xx(10) ... P1-P2 DCB in meters
     452                                   // xx(11) ... dT
     453            xx(12) *= 1e3;         // x-crd at time + dT
     454            xx(13) *= 1e3;         // y-crd at time + dT
     455            xx(14) *= 1e3;         // z-crd at time + dT
     456
     457            pair     = _ephList[prn];
     458            pair->xx = xx;
    469459          }
    470           else {
    471             prn = prns[ii];
    472             if ( _ephList.contains(prn) ) {
    473               t_ephPair* pair = _ephList[prn];
    474               prn = pair->eph->prn();
    475               xx  = pair->xx;
    476               if (oldEph) {
    477                 ep  = pair->oldEph;
    478               }
    479               else {
    480                 ep  = pair->eph;
    481               }
    482             }
     460        }
     461        else {
     462          prn = prns[ii];
     463          if ( _ephList.contains(prn) ) {
     464            pair = _ephList[prn];
     465            xx   = pair->xx;
    483466          }
    484           if (ep != 0) {
    485             struct ClockOrbit::SatData* sd = 0;
     467        }
     468
     469        t_eph* ep = 0;
     470        if (pair) {
     471          ep = pair->eph;
     472          //// ep = pair->oldEph;
     473        }
     474
     475        if (ep != 0) {
     476          struct ClockOrbit::SatData* sd = 0;
     477          if      (prn[0] == 'G') {
     478            sd = co.Sat + co.NumberOfGPSSat;
     479            ++co.NumberOfGPSSat;
     480          }
     481          else if (prn[0] == 'R') {
     482            sd = co.Sat + CLOCKORBIT_NUMGPS + co.NumberOfGLONASSSat;
     483            ++co.NumberOfGLONASSSat;
     484          }
     485          if (sd) {
     486            QString outLine;
     487            processSatellite(ic, _caster.at(ic)->crdTrafo(),
     488                             _caster.at(ic)->CoM(), ep,
     489                             _GPSweek, _GPSweeks, prn, xx, sd, outLine);
     490            _caster.at(ic)->printAscii(outLine);
     491          }
     492
     493          struct Bias::BiasSat* biasSat = 0;
     494          if      (prn[0] == 'G') {
     495            biasSat = bias.Sat + bias.NumberOfGPSSat;
     496            ++bias.NumberOfGPSSat;
     497          }
     498          else if (prn[0] == 'R') {
     499            biasSat = bias.Sat + CLOCKORBIT_NUMGPS + bias.NumberOfGLONASSSat;
     500            ++bias.NumberOfGLONASSSat;
     501          }
     502
     503          // Coefficient of Ionosphere-Free LC
     504          // ---------------------------------
     505          const static double a_L1_GPS =  2.54572778;
     506          const static double a_L2_GPS = -1.54572778;
     507          const static double a_L1_Glo =  2.53125000;
     508          const static double a_L2_Glo = -1.53125000;
     509
     510          if (biasSat) {
     511            biasSat->ID = prn.mid(1).toInt();
     512            biasSat->NumberOfCodeBiases = 3;
    486513            if      (prn[0] == 'G') {
    487               sd = co.Sat + co.NumberOfGPSSat;
    488               ++co.NumberOfGPSSat;
     514              biasSat->Biases[0].Type = CODETYPEGPS_L1_Z;
     515              biasSat->Biases[0].Bias = - a_L2_GPS * xx(10);
     516              biasSat->Biases[1].Type = CODETYPEGPS_L1_CA;
     517              biasSat->Biases[1].Bias = - a_L2_GPS * xx(10) + xx(9);
     518              biasSat->Biases[2].Type = CODETYPEGPS_L2_Z;
     519              biasSat->Biases[2].Bias = a_L1_GPS * xx(10);
    489520            }
    490521            else if (prn[0] == 'R') {
    491               sd = co.Sat + CLOCKORBIT_NUMGPS + co.NumberOfGLONASSSat;
    492               ++co.NumberOfGLONASSSat;
    493             }
    494             if (sd) {
    495               QString outLine;
    496               processSatellite(oldEph, ic, _caster.at(ic)->crdTrafo(),
    497                                _caster.at(ic)->CoM(), ep,
    498                                _GPSweek, _GPSweeks, prn, xx, sd, outLine);
    499               _caster.at(ic)->printAscii(outLine);
    500             }
    501 
    502             struct Bias::BiasSat* biasSat = 0;
    503             if      (prn[0] == 'G') {
    504               biasSat = bias.Sat + bias.NumberOfGPSSat;
    505               ++bias.NumberOfGPSSat;
    506             }
    507             else if (prn[0] == 'R') {
    508               biasSat = bias.Sat + CLOCKORBIT_NUMGPS + bias.NumberOfGLONASSSat;
    509               ++bias.NumberOfGLONASSSat;
    510             }
    511 
    512             // Coefficient of Ionosphere-Free LC
    513             // ---------------------------------
    514             const static double a_L1_GPS =  2.54572778;
    515             const static double a_L2_GPS = -1.54572778;
    516             const static double a_L1_Glo =  2.53125000;
    517             const static double a_L2_Glo = -1.53125000;
    518 
    519             if (biasSat) {
    520               biasSat->ID = prn.mid(1).toInt();
    521               biasSat->NumberOfCodeBiases = 3;
    522               if      (prn[0] == 'G') {
    523                 biasSat->Biases[0].Type = CODETYPEGPS_L1_Z;
    524                 biasSat->Biases[0].Bias = - a_L2_GPS * xx(10);
    525                 biasSat->Biases[1].Type = CODETYPEGPS_L1_CA;
    526                 biasSat->Biases[1].Bias = - a_L2_GPS * xx(10) + xx(9);
    527                 biasSat->Biases[2].Type = CODETYPEGPS_L2_Z;
    528                 biasSat->Biases[2].Bias = a_L1_GPS * xx(10);
    529               }
    530               else if (prn[0] == 'R') {
    531                 biasSat->Biases[0].Type = CODETYPEGLONASS_L1_P;
    532                 biasSat->Biases[0].Bias = - a_L2_Glo * xx(10);
    533                 biasSat->Biases[1].Type = CODETYPEGLONASS_L1_CA;
    534                 biasSat->Biases[1].Bias = - a_L2_Glo * xx(10) + xx(9);
    535                 biasSat->Biases[2].Type = CODETYPEGLONASS_L2_P;
    536                 biasSat->Biases[2].Bias = a_L1_Glo * xx(10);
    537               }
     522              biasSat->Biases[0].Type = CODETYPEGLONASS_L1_P;
     523              biasSat->Biases[0].Bias = - a_L2_Glo * xx(10);
     524              biasSat->Biases[1].Type = CODETYPEGLONASS_L1_CA;
     525              biasSat->Biases[1].Bias = - a_L2_Glo * xx(10) + xx(9);
     526              biasSat->Biases[2].Type = CODETYPEGLONASS_L2_P;
     527              biasSat->Biases[2].Bias = a_L1_Glo * xx(10);
    538528            }
    539529          }
    540530        }
     531      }
    541532     
    542         if ( _caster.at(ic)->usedSocket() &&
    543              (co.NumberOfGPSSat > 0 || co.NumberOfGLONASSSat > 0) ) {
    544           char obuffer[CLOCKORBIT_BUFFERSIZE];
    545 
    546           int len = MakeClockOrbit(&co, COTYPE_AUTO, 0, obuffer, sizeof(obuffer));
    547           if (len > 0) {
    548             if (_caster.at(ic)->ic() == 1)  { emit(newOutBytes1(len));}
    549             if (_caster.at(ic)->ic() == 2)  { emit(newOutBytes2(len));}
    550             if (_caster.at(ic)->ic() == 3)  { emit(newOutBytes3(len));}
    551             if (_caster.at(ic)->ic() == 4)  { emit(newOutBytes4(len));}
    552             if (_caster.at(ic)->ic() == 5)  { emit(newOutBytes5(len));}
    553             if (_caster.at(ic)->ic() == 6)  { emit(newOutBytes6(len));}
    554             if (_caster.at(ic)->ic() == 7)  { emit(newOutBytes7(len));}
    555             if (_caster.at(ic)->ic() == 8)  { emit(newOutBytes8(len));}
    556             if (_caster.at(ic)->ic() == 9)  { emit(newOutBytes9(len));}
    557             if (_caster.at(ic)->ic() == 10) { emit(newOutBytes10(len));}
    558             _caster.at(ic)->write(obuffer, len);
    559           }
    560         }
    561 
    562         if ( _caster.at(ic)->usedSocket() &&
    563              (bias.NumberOfGPSSat > 0 || bias.NumberOfGLONASSSat > 0) ) {
    564           char obuffer[CLOCKORBIT_BUFFERSIZE];
    565           int len = MakeBias(&bias, BTYPE_AUTO, 0, obuffer, sizeof(obuffer));
    566           if (len > 0) {
    567             _caster.at(ic)->write(obuffer, len);
    568           }
     533      if ( _caster.at(ic)->usedSocket() &&
     534           (co.NumberOfGPSSat > 0 || co.NumberOfGLONASSSat > 0) ) {
     535        char obuffer[CLOCKORBIT_BUFFERSIZE];
     536
     537        int len = MakeClockOrbit(&co, COTYPE_AUTO, 0, obuffer, sizeof(obuffer));
     538        if (len > 0) {
     539          if (_caster.at(ic)->ic() == 1)  { emit(newOutBytes1(len));}
     540          if (_caster.at(ic)->ic() == 2)  { emit(newOutBytes2(len));}
     541          if (_caster.at(ic)->ic() == 3)  { emit(newOutBytes3(len));}
     542          if (_caster.at(ic)->ic() == 4)  { emit(newOutBytes4(len));}
     543          if (_caster.at(ic)->ic() == 5)  { emit(newOutBytes5(len));}
     544          if (_caster.at(ic)->ic() == 6)  { emit(newOutBytes6(len));}
     545          if (_caster.at(ic)->ic() == 7)  { emit(newOutBytes7(len));}
     546          if (_caster.at(ic)->ic() == 8)  { emit(newOutBytes8(len));}
     547          if (_caster.at(ic)->ic() == 9)  { emit(newOutBytes9(len));}
     548          if (_caster.at(ic)->ic() == 10) { emit(newOutBytes10(len));}
     549          _caster.at(ic)->write(obuffer, len);
    569550        }
    570551      }
     552
     553      if ( _caster.at(ic)->usedSocket() &&
     554           (bias.NumberOfGPSSat > 0 || bias.NumberOfGLONASSSat > 0) ) {
     555        char obuffer[CLOCKORBIT_BUFFERSIZE];
     556        int len = MakeBias(&bias, BTYPE_AUTO, 0, obuffer, sizeof(obuffer));
     557        if (len > 0) {
     558          _caster.at(ic)->write(obuffer, len);
     559        }
     560      }
    571561    }
    572562  }
     
    575565//
    576566////////////////////////////////////////////////////////////////////////////
    577 void t_bns::processSatellite(int oldEph, int iCaster, const QString trafo,
     567void t_bns::processSatellite(int iCaster, const QString trafo,
    578568                             bool CoM, t_eph* ep, int GPSweek,
    579569                             double GPSweeks, const QString& prn,
     
    648638  }
    649639
    650   char oldCh = (oldEph ? '!' : ' ');
    651   outLine.sprintf("%c %d %.1f %s  %3d  %10.3f  %8.3f %8.3f %8.3f\n",
    652                   oldCh, GPSweek, GPSweeks, ep->prn().toAscii().data(),
     640  outLine.sprintf("%d %.1f %s  %3d  %10.3f  %8.3f %8.3f %8.3f\n",
     641                  GPSweek, GPSweeks, ep->prn().toAscii().data(),
    653642                  ep->IOD(), dClk, rsw(1), rsw(2), rsw(3));
    654643
    655   if (!oldEph && iCaster == 0) {
     644  if (iCaster == 0) {
    656645    if (_rnx) {
    657646      _rnx->write(GPSweek, GPSweeks, prn, xx);
  • trunk/BNS/bns.h

    r2617 r2767  
    7070  void readEpoch();
    7171  void readRecords();
    72   void processSatellite(int oldEph, int iCaster, const QString trafo, bool CoM,
     72  void processSatellite(int iCaster, const QString trafo, bool CoM,
    7373                        t_eph* ep, int GPSweek, double GPSweeks,
    7474                        const QString& prn, const ColumnVector& xx,
Note: See TracChangeset for help on using the changeset viewer.