Changeset 4020 in ntrip


Ignore:
Timestamp:
Apr 22, 2012, 7:24:58 PM (12 years ago)
Author:
mervart
Message:
 
Location:
trunk/BNC
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bncapp.cpp

    r3734 r4020  
    483483void bncApp::printGPSEph(gpsephemeris* ep, bool printFile) {
    484484
    485   QString lineV2;
    486   QString lineV3;
    487 
    488   struct converttimeinfo cti;
    489   converttime(&cti, ep->GPSweek, ep->TOC);
    490 
    491   lineV3.sprintf("G%02d %04d %02d %02d %02d %02d %02d%19.12e%19.12e%19.12e\n",
    492                  ep->satellite, cti.year, cti.month, cti.day, cti.hour,
    493                  cti.minute, cti.second, ep->clock_bias, ep->clock_drift,
    494                  ep->clock_driftrate);
    495 
    496   lineV2.sprintf("%02d %02d %02d %02d %02d %02d%5.1f%19.12e%19.12e%19.12e\n",
    497                  ep->satellite, cti.year%100, cti.month, cti.day, cti.hour,
    498                  cti.minute, (double) cti.second, ep->clock_bias,
    499                  ep->clock_drift, ep->clock_driftrate);
    500 
    501   QString    line;
    502   QByteArray allLines;
    503 
    504   QByteArray fmt;
    505   QByteArray fmt2;
    506   if (_rinexVers == 2) {
    507     fmt  = "   %19.12e%19.12e%19.12e%19.12e\n";
    508     fmt2 = "   %19.12e%19.12e\n";
    509   }
    510   else {
    511     fmt  = "    %19.12e%19.12e%19.12e%19.12e\n";
    512     fmt2 = "    %19.12e%19.12e\n";
    513   }
    514 
    515   line.sprintf(fmt.data(), (double)ep->IODE, ep->Crs, ep->Delta_n, ep->M0);
    516   allLines += line;
    517  
    518   line.sprintf(fmt.data(), ep->Cuc, ep->e, ep->Cus, ep->sqrt_A);
    519   allLines += line;
    520 
    521   line.sprintf(fmt.data(), (double) ep->TOE, ep->Cic, ep->OMEGA0, ep->Cis);
    522   allLines += line;
    523  
    524   line.sprintf(fmt.data(), ep->i0, ep->Crc, ep->omega, ep->OMEGADOT);
    525   allLines += line;
    526 
    527   double dd = 0;
    528   unsigned long ii = ep->flags;
    529   if(ii & GPSEPHF_L2CACODE)
    530     dd += 2.0;
    531   if(ii & GPSEPHF_L2PCODE)
    532     dd += 1.0;
    533   line.sprintf(fmt.data(), ep->IDOT, dd, (double) ep->GPSweek,
    534                ii & GPSEPHF_L2PCODEDATA ? 1.0 : 0.0);
    535   allLines += line;
    536 
    537   if(ep->URAindex <= 6) /* URA index */
    538     dd = ceil(10.0*pow(2.0, 1.0+((double)ep->URAindex)/2.0))/10.0;
    539   else
    540     dd = ceil(10.0*pow(2.0, ((double)ep->URAindex)/2.0))/10.0;
    541   line.sprintf(fmt.data(), dd, ((double) ep->SVhealth), ep->TGD,
    542                ((double) ep->IODC));
    543   allLines += line;
    544 
    545   line.sprintf(fmt2.data(), ((double)ep->TOW), 0.0);
    546   allLines += line;
    547 
    548   printOutput(printFile, _ephStreamGPS, lineV2, lineV3, allLines);
     485  t_ephGPS eph;
     486  eph.set(ep);
     487
     488  QString strV2 = eph.toString(2.11);
     489  QString strV3 = eph.toString(3.01);
     490
     491  printOutput(printFile, _ephStreamGPS, strV2, strV3);
    549492}
    550493
     
    553496void bncApp::printGlonassEph(glonassephemeris* ep, bool printFile) {
    554497
    555   int ww  = ep->GPSWeek;
    556   int tow = ep->GPSTOW;
    557   struct converttimeinfo cti;
    558 
    559   updatetime(&ww, &tow, ep->tb*1000, 1);  // Moscow -> UTC
    560   converttime(&cti, ww, tow);
    561 
    562   int tk = ep->tk-3*60*60;
    563   if (tk < 0) {
    564     tk += 86400;
    565   }
    566 
    567   QString lineV2;
    568   QString lineV3;
    569 
    570   lineV3.sprintf("R%02d %04d %02d %02d %02d %02d %02d%19.12e%19.12e%19.12e\n",
    571                  ep->almanac_number, cti.year, cti.month, cti.day, cti.hour,
    572                  cti.minute, cti.second, -ep->tau, ep->gamma, (double) tk);
    573 
    574   lineV2.sprintf("%02d %02d %02d %02d %02d %02d%5.1f%19.12e%19.12e%19.12e\n",
    575                  ep->almanac_number, cti.year%100, cti.month, cti.day,
    576                  cti.hour, cti.minute, (double) cti.second, -ep->tau,
    577                  ep->gamma, (double) tk);
    578  
    579   QString    line;
    580   QByteArray allLines;
    581 
    582   QByteArray fmt;
    583   if (_rinexVers == 2) {
    584     fmt = "   %19.12e%19.12e%19.12e%19.12e\n";
    585   }
    586   else {
    587     fmt = "    %19.12e%19.12e%19.12e%19.12e\n";
    588   }
    589 
    590   line.sprintf(fmt.data(), ep->x_pos, ep->x_velocity, ep->x_acceleration,
    591                (ep->flags & GLOEPHF_UNHEALTHY) ? 1.0 : 0.0);
    592   allLines += line;
    593    
    594   line.sprintf(fmt.data(), ep->y_pos, ep->y_velocity, ep->y_acceleration,
    595                (double) ep->frequency_number);
    596   allLines += line;
    597  
    598   line.sprintf(fmt.data(), ep->z_pos, ep->z_velocity, ep->z_acceleration,
    599                (double) ep->E);
    600   allLines += line;
    601 
    602   printOutput(printFile, _ephStreamGlonass, lineV2, lineV3, allLines);
     498  t_ephGlo eph;
     499  eph.set(ep);
     500
     501  QString strV2 = eph.toString(2.11);
     502  QString strV3 = eph.toString(3.01);
     503
     504  printOutput(printFile, _ephStreamGPS, strV2, strV3);
    603505}
    604506
     
    607509void bncApp::printGalileoEph(galileoephemeris* ep, bool printFile) {
    608510
    609   QString lineV2;
    610   QString lineV3;
    611 
    612   struct converttimeinfo cti;
    613   converttime(&cti, ep->Week, ep->TOC);
    614 
    615   lineV3.sprintf("E%02d %04d %02d %02d %02d %02d %02d%19.12e%19.12e%19.12e\n",
    616                  ep->satellite, cti.year, cti.month, cti.day, cti.hour,
    617                  cti.minute, cti.second, ep->clock_bias, ep->clock_drift,
    618                  ep->clock_driftrate);
    619 
    620   QString    line;
    621   QByteArray allLines;
    622 
    623   const QByteArray fmt4 = "    %19.12e%19.12e%19.12e%19.12e\n";
    624   const QByteArray fmt3 = "    %19.12e%19.12e%19.12e\n";
    625   const QByteArray fmt1 = "    %19.12e\n";
    626 
    627   line.sprintf(fmt4.data(), (double)ep->IODnav, ep->Crs, ep->Delta_n, ep->M0);
    628   allLines += line;
    629  
    630   line.sprintf(fmt4.data(), ep->Cuc, ep->e, ep->Cus, ep->sqrt_A);
    631   allLines += line;
    632 
    633   line.sprintf(fmt4.data(), (double) ep->TOE, ep->Cic, ep->OMEGA0, ep->Cis);
    634   allLines += line;
    635  
    636   line.sprintf(fmt4.data(), ep->i0, ep->Crc, ep->omega, ep->OMEGADOT);
    637   allLines += line;
    638 
    639   double dataSources = 0.0;       // TODO
    640   line.sprintf(fmt3.data(), ep->IDOT, dataSources, (double) ep->Week);
    641   allLines += line;
    642 
    643   double health   = 0.0;          // TODO
    644   double BGD_1_5B = ep->BGD_1_5A; // TODO
    645   line.sprintf(fmt4.data(), (double) ep->SISA, health, ep->BGD_1_5A, BGD_1_5B);
    646   allLines += line;
    647 
    648   double transmissionTimeOfMessage = 0.9999e9; // unknown (Rinex v3 standard)
    649   line.sprintf(fmt1.data(), transmissionTimeOfMessage);
    650   allLines += line;
    651 
    652   printOutput(printFile, _ephStreamGalileo, lineV2, lineV3, allLines);
     511  t_ephGal eph;
     512  eph.set(ep);
     513
     514  QString strV2 = eph.toString(2.11);
     515  QString strV3 = eph.toString(3.01);
     516
     517  printOutput(printFile, _ephStreamGPS, strV2, strV3);
    653518}
    654519
     
    656521////////////////////////////////////////////////////////////////////////////
    657522void bncApp::printOutput(bool printFile, QTextStream* stream,
    658                          const QString& lineV2,
    659                          const QString& lineV3,
    660                          const QByteArray& allLines) {
     523                         const QString& strV2, const QString& strV3) {
     524
    661525  // Output into file
    662526  // ----------------
    663527  if (printFile && stream) {
    664528    if (_rinexVers == 2) {
    665       *stream << lineV2.toAscii();
     529      *stream << strV2.toAscii();
    666530    }
    667531    else {
    668       *stream << lineV3.toAscii();
    669     }
    670     *stream << allLines;
     532      *stream << strV3.toAscii();
     533    }
    671534    stream->flush();
    672535  }
     
    679542      QTcpSocket* sock = is.next();
    680543      if (sock->state() == QAbstractSocket::ConnectedState) {
    681         if (sock->write(lineV3.toAscii())   == -1 ||
    682             sock->write(allLines)           == -1) {
     544        if (sock->write(strV3.toAscii()) == -1) {
    683545          delete sock;
    684546          is.remove();
  • trunk/BNC/bncapp.h

    r3927 r4020  
    8585    void printGalileoEph(galileoephemeris* ep, bool printFile);
    8686    void printOutput(bool printFile, QTextStream* stream,
    87                      const QString& lineV2,
    88                      const QString& lineV3,
    89                      const QByteArray& allLines);
     87                     const QString& strV2, const QString& strV3);
    9088    void dumpCorrs(long minTime, long maxTime);
    9189    void dumpCorrs();
Note: See TracChangeset for help on using the changeset viewer.