Changeset 589 in ntrip


Ignore:
Timestamp:
Nov 24, 2007, 8:58:16 PM (16 years ago)
Author:
mervart
Message:

* empty log message *

Location:
trunk/BNC
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bncapp.cpp

    r584 r589  
    9191  _ephStreamGlonass = 0;
    9292
     93  _server  = 0;
     94  _sockets = 0;
     95
    9396  _pgmName  = _bncVersion.leftJustified(20, ' ', true);
    9497#ifdef WIN32
     
    108111  delete _ephStreamGPS;
    109112  delete _ephFileGPS;
     113  delete _server;
     114  delete _sockets;
    110115  if (_rinexVers == 2) {
    111116    delete _ephStreamGlonass;
     
    241246      }
    242247      expandEnvVar(_ephPath);
     248    }
     249
     250    // Socket Output
     251    // -------------
     252    _port = settings.value("outEphPort").toInt();
     253    if (_port != 0) {
     254      _server = new QTcpServer;
     255      _server->listen(QHostAddress::Any, _port);
     256      connect(_server, SIGNAL(newConnection()), this, SLOT(slotNewConnection()));
     257      _sockets = new QList<QTcpSocket*>;
    243258    }
    244259  }
     
    456471    converttime(&cti, ep->GPSweek, ep->TOC);
    457472
    458     if      (_rinexVers == 3) {
    459       line.sprintf("G%02d %04d %02d %02d %02d %02d %02d%19.12e%19.12e%19.12e",
    460                    ep->satellite, cti.year, cti.month, cti.day, cti.hour,
    461                    cti.minute, cti.second, ep->clock_bias, ep->clock_drift,
    462                    ep->clock_driftrate);
    463     }
    464     else if (_rinexVers == 2) {
     473    QByteArray stream;
     474
     475    line.sprintf("G%02d %04d %02d %02d %02d %02d %02d%19.12e%19.12e%19.12e",
     476                 ep->satellite, cti.year, cti.month, cti.day, cti.hour,
     477                 cti.minute, cti.second, ep->clock_bias, ep->clock_drift,
     478                 ep->clock_driftrate);
     479    stream += line;
     480    if (_rinexVers == 2) {
    465481      line.sprintf("%02d %02d %02d %02d %02d %02d%5.1f%19.12e%19.12e%19.12e",
    466482                   ep->satellite, cti.year%100, cti.month, cti.day, cti.hour,
     
    472488    line.sprintf("   %19.12e%19.12e%19.12e%19.12e", (double)ep->IODE,
    473489                 ep->Crs, ep->Delta_n, ep->M0);
     490    stream += line;
    474491    *_ephStreamGPS << line << endl;
    475492   
    476493    line.sprintf("   %19.12e%19.12e%19.12e%19.12e", ep->Cuc,
    477494                 ep->e, ep->Cus, ep->sqrt_A);
     495    stream += line;
    478496    *_ephStreamGPS << line << endl;
    479497
    480498    line.sprintf("   %19.12e%19.12e%19.12e%19.12e",
    481499                 (double) ep->TOE, ep->Cic, ep->OMEGA0, ep->Cis);
     500    stream += line;
    482501    *_ephStreamGPS << line << endl;
    483502   
    484503    line.sprintf("   %19.12e%19.12e%19.12e%19.12e", ep->i0,
    485504                 ep->Crc, ep->omega, ep->OMEGADOT);
     505    stream += line;
    486506    *_ephStreamGPS << line << endl;
    487507
     
    494514    line.sprintf("   %19.12e%19.12e%19.12e%19.12e", ep->IDOT, dd,
    495515                 (double) ep->GPSweek, ii & GPSEPHF_L2PCODEDATA ? 1.0 : 0.0);
     516    stream += line;
    496517    *_ephStreamGPS << line << endl;
    497518
     
    502523    line.sprintf("   %19.12e%19.12e%19.12e%19.12e", dd,
    503524                 ((double) ep->SVhealth), ep->TGD, ((double) ep->IODC));
     525    stream += line;
    504526    *_ephStreamGPS << line << endl;
    505527
    506528    line.sprintf("   %19.12e%19.12e", ((double)ep->TOW), 0.0);
     529    stream += line;
    507530    *_ephStreamGPS << line << endl;
    508531
    509532    _ephStreamGPS->flush();
     533
     534    // Output into the socket
     535    // ----------------------
     536    if (_sockets) {
     537      QListIterator<QTcpSocket*> is(*_sockets);
     538      while (is.hasNext()) {
     539        QTcpSocket* sock = is.next();
     540        if (sock->state() == QAbstractSocket::ConnectedState) {
     541          sock->write(stream);
     542        }
     543      }
     544    }
    510545  }
    511546}
     
    560595  }
    561596}
     597
     598// New Connection
     599////////////////////////////////////////////////////////////////////////////
     600void bncApp::slotNewConnection() {
     601  _sockets->push_back( _server->nextPendingConnection() );
     602}
     603
  • trunk/BNC/bncapp.h

    r559 r589  
    4343    void slotNewGPSEph(gpsephemeris* gpseph);
    4444    void slotNewGlonassEph(glonassephemeris* glonasseph);
     45 private slots:
     46   void slotNewConnection();
    4547  private:
    4648    void printEphHeader();
     
    6466    QString           _userName;
    6567    QString           _pgmName;
     68    int                 _port;
     69    QTcpServer*         _server;
     70    QList<QTcpSocket*>* _sockets;
    6671};
    6772#endif
Note: See TracChangeset for help on using the changeset viewer.