Changeset 420 in ntrip


Ignore:
Timestamp:
Mar 28, 2007, 2:01:36 PM (17 years ago)
Author:
mervart
Message:

* empty log message *

Location:
trunk/BNC
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bncrinex.cpp

    r419 r420  
    9393}
    9494
     95// Download Skeleton Header File
     96////////////////////////////////////////////////////////////////////////////
     97t_irc bncRinex::downloadSkeleton() {
     98
     99  t_irc irc = failure;
     100
     101  QStringList table;
     102  bncTableDlg::getFullTable(_mountPoint.host(), _mountPoint.port(),
     103                            table, false);
     104  QString net;
     105  QStringListIterator it(table);
     106  while (it.hasNext()) {
     107    QString line = it.next();
     108    if (line.indexOf("STR") == 0) {
     109      QStringList tags = line.split(";");
     110      if (tags.at(1) == _mountPoint.path().mid(1).toAscii()) {
     111        net = tags.at(7);
     112        break;
     113      }
     114    }
     115  }
     116  QString sklDir;
     117  it.toFront();
     118  while (it.hasNext()) {
     119    QString line = it.next();
     120    if (line.indexOf("NET") == 0) {
     121      QStringList tags = line.split(";");
     122      if (tags.at(1) == net) {
     123        sklDir = tags.at(6).trimmed();
     124        break;
     125      }         
     126    }
     127  }
     128  if (!sklDir.isEmpty() && sklDir != "none") {
     129    QUrl url(sklDir + "/" + _mountPoint.path().mid(1,4).toLower() + ".skl");
     130    if (url.port() == -1) {
     131      url.setPort(80);
     132    }
     133
     134    const int timeOut = 10*1000;
     135    QString msg;
     136    QByteArray _latitude;
     137    QByteArray _longitude;
     138    QByteArray _nmea;
     139    QTcpSocket* socket = bncGetThread::request(url, _latitude, _longitude, _nmea, timeOut, msg);
     140
     141    if (socket) {
     142      _skeletonLines.clear();
     143      while (true) {
     144        if (socket->canReadLine()) {
     145          _skeletonLines.append( socket->readLine() );
     146          irc = success;
     147        }
     148        else {
     149          socket->waitForReadyRead(timeOut);
     150          if (socket->bytesAvailable() > 0) {
     151            continue;
     152          }
     153          else {
     154            break;
     155          }
     156        }
     157      }
     158      delete socket;
     159    }
     160  }
     161  return irc;
     162}
     163
    95164// Read Skeleton Header File
    96165////////////////////////////////////////////////////////////////////////////
     
    99168  _headerLines.clear();
    100169
    101   // Read the File
    102   // -------------
     170  // Read the local file
     171  // -------------------
    103172  QFile skl(_sklName);
    104173  if ( skl.exists() && skl.open(QIODevice::ReadOnly) ) {
     
    112181  }
    113182
    114   // Try to download the skeleton file
    115   // ---------------------------------
     183  // Read downloaded file
     184  // --------------------
    116185  else {
    117     QStringList table;
    118     bncTableDlg::getFullTable(_mountPoint.host(), _mountPoint.port(),
    119                               table, false);
    120     QString net;
    121     QStringListIterator it(table);
     186    QDate currDate = QDate::currentDate();
     187    if ( !_skeletonDate.isValid() || _skeletonDate != currDate ) {
     188      if ( downloadSkeleton() == success) {
     189        _skeletonDate = currDate;
     190      }
     191    }
     192    bool firstLineRead = false;
     193    QStringListIterator it(_skeletonLines);
    122194    while (it.hasNext()) {
    123195      QString line = it.next();
    124       if (line.indexOf("STR") == 0) {
    125         QStringList tags = line.split(";");
    126         if (tags.at(1) == _mountPoint.path().mid(1).toAscii()) {
    127           net = tags.at(7);
     196      line.chop(1);
     197      if (line.indexOf("RINEX VERSION") != -1) {
     198        _headerLines.append("     2.11           OBSERVATION DATA"
     199                            "    M (MIXED)"
     200                            "           RINEX VERSION / TYPE");
     201        _headerLines.append("PGM / RUN BY / DATE");
     202        firstLineRead = true;
     203      }
     204      else if (firstLineRead) {
     205        if (line.indexOf("END OF HEADER") != -1) {
     206          _headerLines.append("# / TYPES OF OBSERV");
     207          _headerLines.append(
     208                QString("     1     1").leftJustified(60, ' ', true) +
     209                "WAVELENGTH FACT L1/2");
     210          _headerLines.append("TIME OF FIRST OBS");
     211          _headerLines.append( line );
    128212          break;
    129213        }
    130       }
    131     }
    132     QString sklDir;
    133     it.toFront();
    134     while (it.hasNext()) {
    135       QString line = it.next();
    136       if (line.indexOf("NET") == 0) {
    137         QStringList tags = line.split(";");
    138         if (tags.at(1) == net) {
    139           sklDir = tags.at(6).trimmed();
    140           break;
    141         }         
    142       }
    143     }
    144     if (!sklDir.isEmpty() && sklDir != "none") {
    145       QUrl url(sklDir + "/" + _mountPoint.path().mid(1,4).toLower() + ".skl");
    146       if (url.port() == -1) {
    147         url.setPort(80);
    148       }
    149 
    150       const int timeOut = 10*1000;
    151       QString msg;
    152       QByteArray _latitude;
    153       QByteArray _longitude;
    154       QByteArray _nmea;
    155       QTcpSocket* socket = bncGetThread::request(url, _latitude, _longitude, _nmea, timeOut, msg);
    156 
    157       if (socket) {
    158         bool firstLineRead = false;
    159         while (true) {
    160           if (socket->canReadLine()) {
    161             QString line = socket->readLine();
    162             line.chop(1);
    163             if (line.indexOf("RINEX VERSION") != -1) {
    164               _headerLines.append("     2.11           OBSERVATION DATA"
    165                                   "    M (MIXED)"
    166                                   "           RINEX VERSION / TYPE");
    167               _headerLines.append("PGM / RUN BY / DATE");
    168 //            _headerLines.append(
    169 //                         QString("unknown").leftJustified(60, ' ', true) +
    170 //                         "OBSERVER / AGENCY");
    171               firstLineRead = true;
    172             }
    173             else if (firstLineRead) {
    174               if (line.indexOf("END OF HEADER") != -1) {
    175                 _headerLines.append("# / TYPES OF OBSERV");
    176                 _headerLines.append(
    177                       QString("     1     1").leftJustified(60, ' ', true) +
    178                       "WAVELENGTH FACT L1/2");
    179                 _headerLines.append("TIME OF FIRST OBS");
    180                 _headerLines.append( line );
    181                 break;
    182               }
    183               else {
    184                 _headerLines.append( line );
    185               }
    186             }
    187           }
    188           else {
    189             socket->waitForReadyRead(timeOut);
    190             if (socket->bytesAvailable() > 0) {
    191               continue;
    192             }
    193             else {
    194               break;
    195             }
    196           }
     214        else {
     215          _headerLines.append( line );
    197216        }
    198         delete socket;
    199217      }
    200218    }
  • trunk/BNC/bncrinex.h

    r408 r420  
    3434#include <fstream>
    3535
     36#include "bncconst.h"
    3637#include "RTCM/GPSDecoder.h"
    3738
     
    5152   void writeHeader(const QDateTime& datTim, const QDateTime& datTimNom);
    5253   void closeFile();
     54   t_irc downloadSkeleton();
    5355
    5456   QByteArray          _statID;
     
    6971   QByteArray          _nmea;
    7072   bool                _reconnectFlag;
     73   QStringList         _skeletonLines;
     74   QDate               _skeletonDate;
    7175};
    7276
Note: See TracChangeset for help on using the changeset viewer.