Changeset 941 in ntrip for trunk/BNC/bncapp.cpp


Ignore:
Timestamp:
Jun 9, 2008, 3:55:19 PM (16 years ago)
Author:
mervart
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bncapp.cpp

    r937 r941  
    393393void bncApp::printGPSEph(gpsephemeris* ep, bool printFile) {
    394394
    395   QString line;
    396   QByteArray allLines;
     395  QString lineV2;
     396  QString lineV3;
    397397
    398398  struct converttimeinfo cti;
    399399  converttime(&cti, ep->GPSweek, ep->TOC);
    400   if      (_rinexVers == 3) {
    401     line.sprintf("G%02d %04d %02d %02d %02d %02d %02d %18.11e %18.11e %18.11e\n",
     400
     401  lineV3.sprintf("G%02d %04d %02d %02d %02d %02d %02d %18.11e %18.11e %18.11e\n",
    402402                 ep->satellite, cti.year, cti.month, cti.day, cti.hour,
    403403                 cti.minute, cti.second, ep->clock_bias, ep->clock_drift,
    404404                 ep->clock_driftrate);
    405   }
    406   else if (_rinexVers == 2) {
    407     line.sprintf("%02d %02d %02d %02d %02d %02d%5.1f %18.11e %18.11e %18.11e\n",
     405
     406  lineV2.sprintf("%02d %02d %02d %02d %02d %02d%5.1f %18.11e %18.11e %18.11e\n",
    408407                 ep->satellite, cti.year%100, cti.month, cti.day, cti.hour,
    409408                 cti.minute, (double) cti.second, ep->clock_bias,
    410409                 ep->clock_drift, ep->clock_driftrate);
    411   }
    412   allLines += line;
     410
     411  QString    line;
     412  QByteArray allLines;
    413413
    414414  line.sprintf("    %18.11e %18.11e %18.11e %18.11e\n", (double)ep->IODE,
     
    449449  allLines += line;
    450450
     451  printOutput(printFile, lineV2, lineV3, allLines);
     452}
     453
     454// Print One Glonass Ephemeris
     455////////////////////////////////////////////////////////////////////////////
     456void bncApp::printGlonassEph(glonassephemeris* ep, bool printFile) {
     457
     458  int ww  = ep->GPSWeek;
     459  int tow = ep->GPSTOW;
     460  struct converttimeinfo cti;
     461
     462  updatetime(&ww, &tow, ep->tb*1000, 0);
     463  converttime(&cti, ww, tow);
     464
     465  int tk = ep->tk-3*60*60;
     466  if (tk < 0) {
     467    tk += 86400;
     468  }
     469
     470  QString lineV2;
     471  QString lineV3;
     472
     473  lineV3.sprintf("R%02d %04d %02d %02d %02d %02d %02d %18.11e %18.11e %18.11e\n",
     474                 ep->almanac_number, cti.year, cti.month, cti.day, cti.hour,
     475                 cti.minute, cti.second, -ep->tau, ep->gamma, (double) tk);
     476
     477  lineV2.sprintf("%02d %02d %02d %02d %02d %02d%5.1f %18.11e %18.11e %18.11e\n",
     478                 ep->almanac_number, cti.year%100, cti.month, cti.day,
     479                 cti.hour, cti.minute, (double) cti.second, -ep->tau,
     480                 ep->gamma, (double) tk);
     481 
     482  QString    line;
     483  QByteArray allLines;
     484
     485  line.sprintf("    %18.11e %18.11e %18.11e %18.11e\n", ep->x_pos,
     486               ep->x_velocity, ep->x_acceleration,
     487               (ep->flags & GLOEPHF_UNHEALTHY) ? 1.0 : 0.0);
     488  allLines += line;
     489   
     490  line.sprintf("    %18.11e %18.11e %18.11e %18.11e\n", ep->y_pos,
     491               ep->y_velocity, ep->y_acceleration,
     492               (double) ep->frequency_number);
     493  allLines += line;
     494 
     495  line.sprintf("    %18.11e %18.11e %18.11e %18.11e\n", ep->z_pos,
     496               ep->z_velocity, ep->z_acceleration, (double) ep->E);
     497  allLines += line;
     498
     499  printOutput(printFile, lineV2, lineV3, allLines);
     500}
     501
     502// Output
     503////////////////////////////////////////////////////////////////////////////
     504void bncApp::printOutput(bool printFile, const QString& lineV2,
     505                         const QString& lineV3,
     506                         const QByteArray& allLines) {
    451507  // Output into file
    452508  // ----------------
    453509  if (printFile && _ephStreamGPS) {
     510    if (_rinexVers == 2) {
     511      *_ephStreamGPS << lineV2.toAscii();
     512    }
     513    else {
     514      *_ephStreamGPS << lineV3.toAscii();
     515    }
    454516    *_ephStreamGPS << allLines;
    455517    _ephStreamGPS->flush();
     
    463525      QTcpSocket* sock = is.next();
    464526      if (sock->state() == QAbstractSocket::ConnectedState) {
    465         if (sock->write(allLines) == -1) {
    466           delete sock;
    467           is.remove();
    468         }
    469       }
    470       else if (sock->state() != QAbstractSocket::ConnectingState) {
    471         delete sock;
    472         is.remove();
    473       }
    474     }
    475   }
    476 }
    477 
    478 // Print One Glonass Ephemeris
    479 ////////////////////////////////////////////////////////////////////////////
    480 void bncApp::printGlonassEph(glonassephemeris* ep, bool printFile) {
    481 
    482   QString line;
    483   QByteArray allLines;
    484 
    485   int ww  = ep->GPSWeek;
    486   int tow = ep->GPSTOW;
    487   struct converttimeinfo cti;
    488 
    489   updatetime(&ww, &tow, ep->tb*1000, 0);
    490   converttime(&cti, ww, tow);
    491 
    492   int tk = ep->tk-3*60*60;
    493   if (tk < 0) {
    494     tk += 86400;
    495   }
    496 
    497   if      (_rinexVers == 3) {
    498     line.sprintf("R%02d %04d %02d %02d %02d %02d %02d %18.11e %18.11e %18.11e\n",
    499                  ep->almanac_number, cti.year, cti.month, cti.day, cti.hour,
    500                  cti.minute, cti.second, -ep->tau, ep->gamma, (double) tk);
    501   }
    502   else if (_rinexVers == 2) {
    503     line.sprintf("%02d %02d %02d %02d %02d %02d%5.1f %18.11e %18.11e %18.11e\n",
    504                  ep->almanac_number, cti.year%100, cti.month, cti.day,
    505                  cti.hour, cti.minute, (double) cti.second, -ep->tau,
    506                  ep->gamma, (double) tk);
    507   }
    508   allLines += line;
    509  
    510   line.sprintf("    %18.11e %18.11e %18.11e %18.11e\n", ep->x_pos,
    511                ep->x_velocity, ep->x_acceleration,
    512                (ep->flags & GLOEPHF_UNHEALTHY) ? 1.0 : 0.0);
    513   allLines += line;
    514    
    515   line.sprintf("    %18.11e %18.11e %18.11e %18.11e\n", ep->y_pos,
    516                ep->y_velocity, ep->y_acceleration,
    517                (double) ep->frequency_number);
    518   allLines += line;
    519  
    520   line.sprintf("    %18.11e %18.11e %18.11e %18.11e\n", ep->z_pos,
    521                ep->z_velocity, ep->z_acceleration, (double) ep->E);
    522   allLines += line;
    523 
    524   // Output into file
    525   // ----------------
    526   if (printFile && _ephStreamGlonass) {
    527     *_ephStreamGlonass << allLines;
    528     _ephStreamGlonass->flush();
    529   }
    530 
    531   // Output into the socket
    532   // ----------------------
    533   if (_sockets) {
    534     QMutableListIterator<QTcpSocket*> is(*_sockets);
    535     while (is.hasNext()) {
    536       QTcpSocket* sock = is.next();
    537       if (sock->state() == QAbstractSocket::ConnectedState) {
    538         if (sock->write(allLines) == -1) {
     527        if (sock->write(lineV3.toAscii())   == -1 ||
     528            sock->write(allLines)           == -1) {
    539529          delete sock;
    540530          is.remove();
Note: See TracChangeset for help on using the changeset viewer.