Changeset 934 in ntrip


Ignore:
Timestamp:
Jun 8, 2008, 4:33:04 PM (16 years ago)
Author:
mervart
Message:

* empty log message *

Location:
trunk/BNC
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/RTCM3/RTCM3coDecoder.cpp

    r920 r934  
    4444#include "RTCM3coDecoder.h"
    4545#include "bncutils.h"
     46#include "bncrinex.h"
    4647
    4748using namespace std;
     
    4950// Constructor
    5051////////////////////////////////////////////////////////////////////////////
    51 RTCM3coDecoder::RTCM3coDecoder(const QString& fileName)
    52   : bncZeroDecoder(fileName) {
     52RTCM3coDecoder::RTCM3coDecoder(const QString& fileName) {
     53
     54  // File Output
     55  // -----------
     56  QSettings settings;
     57  QString path = settings.value("corrPath").toString();
     58  if (!path.isEmpty()) {
     59    expandEnvVar(path);
     60    if ( path.length() > 0 && path[path.length()-1] != QDir::separator() ) {
     61      path += QDir::separator();
     62    }
     63    _fileNameSkl = path + fileName;
     64  }
     65  _out = 0;
     66
     67  // Socket Server
     68  // -------------
     69  int port = settings.value("corrPort").toInt();
     70  if (port != 0) {
     71    _server = new QTcpServer;
     72    _server->listen(QHostAddress::Any, port);
     73    connect(_server, SIGNAL(newConnection()), this, SLOT(slotNewConnection()));
     74    _sockets = new QList<QTcpSocket*>;
     75  }
     76  else {
     77    delete _sockets;
     78    delete _server;
     79  }
    5380}
    5481
     
    5683////////////////////////////////////////////////////////////////////////////
    5784RTCM3coDecoder::~RTCM3coDecoder() {
     85}
     86
     87// Reopen Output File
     88////////////////////////////////////////////////////////////////////////
     89void RTCM3coDecoder::reopen() {
     90
     91  if (!_fileNameSkl.isEmpty()) {
     92
     93    QSettings settings;
     94
     95    QDateTime datTim = QDateTime::currentDateTime().toUTC();
     96
     97    QString hlpStr = bncRinex::nextEpochStr(datTim,
     98                                      settings.value("corrIntr").toString());
     99
     100    QString fileName = _fileNameSkl
     101      + QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0'))
     102      + datTim.toString(".yyC");
     103
     104    if (_fileName == fileName) {
     105      return;
     106    }
     107    else {
     108      _fileName = fileName;
     109    }
     110
     111    delete _out;
     112    _out = new ofstream( _fileName.toAscii().data() );
     113  }
     114}
     115
     116// New Connection
     117////////////////////////////////////////////////////////////////////////////
     118void RTCM3coDecoder::slotNewConnection() {
     119  _sockets->push_back( _server->nextPendingConnection() );
    58120}
    59121
     
    126188               _co.Sat[ii].Orbit.DeltaAlongTrack,
    127189               _co.Sat[ii].Orbit.DeltaCrossTrack);
    128         *_out << line.toAscii().data();
     190        printLine(line);
    129191      }
    130192      for(int ii = CLOCKORBIT_NUMGPS;
     
    137199               _co.Sat[ii].Orbit.DeltaAlongTrack,
    138200               _co.Sat[ii].Orbit.DeltaCrossTrack);
    139         *_out << line.toAscii().data();
    140       }
    141       _out->flush();
     201        printLine(line);
     202      }
    142203      _buffer = _buffer.substr(bytesused);
    143204      return success;
     
    151212  }
    152213}
     214
     215//
     216////////////////////////////////////////////////////////////////////////////
     217void RTCM3coDecoder::printLine(const QString& line) {
     218
     219  if (_out) {
     220    *_out << line.toAscii().data();
     221    _out->flush();
     222  }
     223
     224  if (_sockets) {
     225    QMutableListIterator<QTcpSocket*> is(*_sockets);
     226    while (is.hasNext()) {
     227      QTcpSocket* sock = is.next();
     228      if (sock->state() == QAbstractSocket::ConnectedState) {
     229        if (sock->write(line.toAscii()) == -1) {
     230          delete sock;
     231          is.remove();
     232        }
     233      }
     234      else if (sock->state() != QAbstractSocket::ConnectingState) {
     235        delete sock;
     236        is.remove();
     237      }
     238    }
     239  }
     240}
  • trunk/BNC/RTCM3/RTCM3coDecoder.h

    r908 r934  
    2626#define RTCM3CODECODER_H
    2727
    28 #include "bnczerodecoder.h"
     28#include <fstream>
     29
     30#include <QtCore>
     31#include <QtNetwork>
     32
     33#include "RTCM/GPSDecoder.h"
    2934
    3035extern "C" {
     
    3237}
    3338
    34 class RTCM3coDecoder : public bncZeroDecoder {
    35 public:
     39class RTCM3coDecoder : public QObject, public GPSDecoder {
     40Q_OBJECT
     41 public:
    3642  RTCM3coDecoder(const QString& fileName);
    3743  virtual ~RTCM3coDecoder();
    3844  virtual t_irc Decode(char* buffer = 0, int bufLen = 0);
    39 private:
    40   std::string _buffer;
    41   ClockOrbit  _co;
    42   Bias        _bias;
    43 } ;
     45
     46 private slots:
     47  void slotNewConnection();
     48
     49 private:
     50  void reopen();
     51  void printLine(const QString& line);
     52
     53  std::ofstream*      _out;
     54  QString             _fileNameSkl;
     55  QString             _fileName;
     56  std::string         _buffer;
     57  ClockOrbit          _co;
     58  Bias                _bias;
     59  QTcpServer*         _server;
     60  QList<QTcpSocket*>* _sockets;
     61};
    4462
    4563#endif
  • trunk/BNC/bncapp.cpp

    r901 r934  
    457457      QTcpSocket* sock = is.next();
    458458      if (sock->state() == QAbstractSocket::ConnectedState) {
    459         int fd = sock->socketDescriptor();
    460         if (::write(fd, allLines.data(), allLines.size()) != allLines.size()) {
     459        if (sock->write(allLines) == -1) {
    461460          delete sock;
    462461          is.remove();
     
    531530      QTcpSocket* sock = is.next();
    532531      if (sock->state() == QAbstractSocket::ConnectedState) {
    533         int fd = sock->socketDescriptor();
    534         if (::write(fd, allLines.data(), allLines.size()) != allLines.size()) {
     532        if (sock->write(allLines) == -1) {
    535533          delete sock;
    536534          is.remove();
  • trunk/BNC/bncwindow.cpp

    r919 r934  
    117117  _outEphPortLineEdit    = new QLineEdit(settings.value("outEphPort").toString());
    118118  _outEphPortLineEdit->setMaximumWidth(9*ww);
     119  _corrPortLineEdit    = new QLineEdit(settings.value("corrPort").toString());
     120  _corrPortLineEdit->setMaximumWidth(9*ww);
    119121  _rnxPathLineEdit    = new QLineEdit(settings.value("rnxPath").toString());
    120122  _ephPathLineEdit    = new QLineEdit(settings.value("ephPath").toString());
     123  _corrPathLineEdit    = new QLineEdit(settings.value("ephPath").toString());
    121124
    122125  _rnxV3CheckBox = new QCheckBox();
     
    145148  if (jj != -1) {
    146149    _ephIntrComboBox->setCurrentIndex(jj);
     150  }
     151  _corrIntrComboBox    = new QComboBox();
     152  _corrIntrComboBox->setMaximumWidth(9*ww);
     153  _corrIntrComboBox->setEditable(false);
     154  _corrIntrComboBox->addItems(QString("1 min,2 min,5 min,10 min,15 min,30 min,1 hour,1 day").split(","));
     155  int mm = _corrIntrComboBox->findText(settings.value("corrIntr").toString());
     156  if (mm != -1) {
     157    _corrIntrComboBox->setCurrentIndex(mm);
    147158  }
    148159  _rnxSamplSpinBox    = new QSpinBox();
     
    282293  _outPortLineEdit->setWhatsThis(tr("BNC can produce synchronized observations in binary format on your local host through an IP port. Specify a port number here to activate this function."));
    283294  _outEphPortLineEdit->setWhatsThis(tr("BNC can produce ephemeris data in RINEX ASCII format on your local host through an IP port. Specify a port number here to activate this function."));
     295  _corrPortLineEdit->setWhatsThis(tr("BNC can produce ephemeris corrections on your local host through an IP port. Specify a port number here to activate this function."));
    284296  _rnxPathLineEdit->setWhatsThis(tr("Here you specify the path to where the RINEX Observation files will be stored. If the specified directory does not exist, BNC will not create RINEX Observation files."));
    285297  _ephPathLineEdit->setWhatsThis(tr("Specify the path for saving Broadcast Ephemeris data as RINEX Navigation files. If the specified directory does not exist, BNC will not create RINEX Navigation files."));
     298  _corrPathLineEdit->setWhatsThis(tr("Specify the path for saving Broadcast Ephemeris corrections. If the specified directory does not exist, BNC will not create the files."));
    286299  _rnxScrpLineEdit->setWhatsThis(tr("<p>Whenever a RINEX Observation file is saved, you might want to compress, copy or upload it immediately via FTP. BNC allows you to execute a script/batch file to carry out these operations. To do that specify the full path of the script/batch file here. BNC will pass the full RINEX Observation file path to the script as a command line parameter (%1 on Windows systems, $1 onUnix/Linux systems).</p><p>The triggering event for calling the script or batch file is the end of a RINEX Observation file 'Interval'. If that is overridden by a stream outage, the triggering event is the stream reconnection.</p>"));
    287300  _rnxSkelLineEdit->setWhatsThis(tr("<p>Whenever BNC starts generating RINEX Observation files (and then once every day at midnight), it first tries to retrieve information needed for RINEX headers from so-called public RINEX header skeleton files which are derived from sitelogs. However, sometimes public RINEX header skeleton files are not available, its contents is not up to date, or you need to put additional/optional records in the RINEX header.</p><p>For that BNC allows using personal skeleton files that contain the header records you would like to include. You can derive a personal RINEX header skeleton file from the information given in an up to date sitelog. A file in the RINEX 'Directory' with the RINEX 'Skeleton extension' is interpreted by BNC as a personal RINEX header skeleton file for the corresponding stream.</p>"));
     
    289302  _rnxIntrComboBox->setWhatsThis(tr("<p>Select the length of the RINEX Observation file.</p>"));
    290303  _ephIntrComboBox->setWhatsThis(tr("<p>Select the length of the RINEX Navigation file.</p>"));
     304  _corrIntrComboBox->setWhatsThis(tr("<p>Select the length of the correction file.</p>"));
    291305  _rnxSamplSpinBox->setWhatsThis(tr("<p>Select the RINEX Observation sampling interval in seconds. A value of zero '0' tells BNC to store all received epochs into RINEX.</p>"));
    292306  _binSamplSpinBox->setWhatsThis(tr("<p>Select the Observation sampling interval in seconds. A value of zero '0' tells BNC to send/store all received epochs.</p>"));
     
    314328  QWidget* egroup = new QWidget();
    315329  QWidget* agroup = new QWidget();
     330  QWidget* cgroup = new QWidget();
    316331  QWidget* ogroup = new QWidget();
    317332  aogroup->addTab(pgroup,tr("Proxy"));
     
    320335  aogroup->addTab(egroup,tr("RINEX Ephemeris"));
    321336  aogroup->addTab(sgroup,tr("Synchronized Observations"));
     337  aogroup->addTab(cgroup,tr("Ephemeris Corrections"));
    322338  aogroup->addTab(agroup,tr("Monitor"));
    323339
     
    415431  ogroup->setLayout(oLayout);
    416432 
     433  QGridLayout* cLayout = new QGridLayout;
     434  cLayout->setColumnMinimumWidth(0,12*ww);
     435  cLayout->addWidget(new QLabel("Directory"),                     0, 0);
     436  cLayout->addWidget(_corrPathLineEdit,                           0, 1);
     437  cLayout->addWidget(new QLabel("Interval"),                      1, 0);
     438  cLayout->addWidget(_corrIntrComboBox,                           1, 1);
     439  cLayout->addWidget(new QLabel("Port"),                          2, 0);
     440  cLayout->addWidget(_corrPortLineEdit,                           2, 1);
     441  cLayout->addWidget(new QLabel("Saving ephemeris correction files and correction output through IP port."),3,0,1,2,Qt::AlignLeft);
     442  cLayout->addWidget(new QLabel("    "),4,0);
     443  cgroup->setLayout(cLayout);
     444
    417445  QVBoxLayout* mLayout = new QVBoxLayout;
    418446  mLayout->addWidget(aogroup);
     
    555583  settings.setValue("outPort",     _outPortLineEdit->text());
    556584  settings.setValue("outEphPort",  _outEphPortLineEdit->text());
     585  settings.setValue("corrPort",    _corrPortLineEdit->text());
    557586  settings.setValue("rnxPath",     _rnxPathLineEdit->text());
    558587  settings.setValue("ephPath",     _ephPathLineEdit->text());
     588  settings.setValue("corrPath",    _corrPathLineEdit->text());
    559589  settings.setValue("rnxScript",   _rnxScrpLineEdit->text());
    560590  settings.setValue("rnxIntr",     _rnxIntrComboBox->currentText());
    561591  settings.setValue("ephIntr",     _ephIntrComboBox->currentText());
     592  settings.setValue("corrIntr",    _corrIntrComboBox->currentText());
    562593  settings.setValue("rnxSampl",    _rnxSamplSpinBox->value());
    563594  settings.setValue("binSampl",    _binSamplSpinBox->value());
  • trunk/BNC/bncwindow.h

    r740 r934  
    9090    QLineEdit* _outPortLineEdit;
    9191    QLineEdit* _outEphPortLineEdit;
     92    QLineEdit* _corrPortLineEdit;
    9293    QLineEdit* _rnxPathLineEdit;
    9394    QLineEdit* _ephPathLineEdit;
     95    QLineEdit* _corrPathLineEdit;
    9496    QCheckBox* _rnxV3CheckBox;
    9597    QCheckBox* _ephV3CheckBox;
     
    99101    QComboBox* _rnxIntrComboBox;
    100102    QComboBox* _ephIntrComboBox;
     103    QComboBox* _corrIntrComboBox;
    101104    QSpinBox*  _rnxSamplSpinBox;
    102105    QSpinBox*  _binSamplSpinBox;
  • trunk/BNC/bnczerodecoder.cpp

    r881 r934  
    4848////////////////////////////////////////////////////////////////////////
    4949bncZeroDecoder::bncZeroDecoder(const QString& fileName) {
     50
    5051  QSettings settings;
    5152  QString path = settings.value("rnxPath").toString();
  • trunk/BNC/bnczerodecoder.h

    r875 r934  
    3535  ~bncZeroDecoder();
    3636  virtual t_irc Decode(char* buffer, int bufLen);
    37  protected:
     37 private:
    3838  void reopen();
    3939  QString        _fileName;
    4040  std::ofstream* _out;
    41  private:
    4241  QDate          _fileDate;
    4342};
Note: See TracChangeset for help on using the changeset viewer.