Changeset 863 in ntrip


Ignore:
Timestamp:
May 5, 2008, 10:52:55 AM (16 years ago)
Author:
mervart
Message:

* empty log message *

Location:
trunk/BNS
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNS/bns.cpp

    r862 r863  
    2323#include "bnsrinex.h"
    2424#include "bnssp3.h"
    25 extern "C" {
    26 #include "RTCM/clock_orbit_rtcm.h"
    27 }
    2825
    2926using namespace std;
     
    315312  in >> hlp >> GPSweek >> GPSweeks >> numSat;
    316313
    317   for (int ii = 1; ii <= numSat; ii++) {
    318     line = _clkSocket->readLine();
    319 
    320     QTextStream in(line);
    321 
    322     QString      prn;
    323     ColumnVector xx(4);
    324 
    325     in >> prn >> xx(1) >> xx(2) >> xx(3) >> xx(4);
    326     xx(4) *= 1e-6;
    327 
    328     processSatellite(GPSweek, GPSweeks, prn, xx);
    329   }
    330 }
    331 
    332 //
    333 ////////////////////////////////////////////////////////////////////////////
    334 void t_bns::processSatellite(int GPSweek, double GPSweeks, const QString& prn,
    335                              const ColumnVector& xx) {
    336 
    337   // No broadcast ephemeris available
    338   // --------------------------------
    339   if ( !_ephList.contains(prn) ) {
    340     return;
    341   }
    342 
    343   t_ephPair* pair = _ephList[prn];
    344   gpsEph*    ep   = pair->eph;
    345 
    346   ColumnVector xB(4);
    347   ColumnVector vv(3);
    348 
    349   satellitePosition(GPSweek, GPSweeks, ep, xB(1), xB(2), xB(3), xB(4),
    350                     vv(1), vv(2), vv(3));
    351 
    352   ColumnVector dx   = xx.Rows(1,3) - xB.Rows(1,3);
    353   double       dClk = (xx(4) - xB(4)) * 299792458.0;
    354   ColumnVector rsw(3);
    355 
    356   XYZ_to_RSW(xB.Rows(1,3), vv, dx, rsw);
    357 
    358   QString line;
    359   line.sprintf("%d %.1f %s   %3d %3d   %8.3f   %8.3f %8.3f %8.3f\n",
    360                GPSweek, GPSweeks, ep->prn.toAscii().data(),
    361                int(ep->IODC), int(ep->IODE), dClk, rsw(1), rsw(2), rsw(3));
    362  
    363   if (_outStream) {
    364     *_outStream << line;
    365     _outStream->flush();
    366   }
    367   if (_outSocket) {
     314  if (numSat > 0) {
     315
    368316    struct ClockOrbit co;
    369317    memset(&co, 0, sizeof(co));
     
    373321    co.SatRefPoint       = POINT_CENTER;
    374322    co.SatRefDatum       = DATUM_ITRF;
    375     co.NumberOfGPSSat    = 1;
    376 
    377     struct ClockOrbit::SatData* sd = co.Sat;
    378     ///    sd->ID                    = prn;
     323
     324    for (int ii = 1; ii <= numSat; ii++) {
     325      line = _clkSocket->readLine();
     326   
     327      QTextStream in(line);
     328   
     329      QString      prn;
     330      ColumnVector xx(4);
     331   
     332      in >> prn >> xx(1) >> xx(2) >> xx(3) >> xx(4);
     333      xx(4) *= 1e-6;
     334   
     335      struct ClockOrbit::SatData* sd = 0;
     336      if      (prn[0] == 'G') {
     337        sd = co.Sat + co.NumberOfGPSSat;
     338        ++co.NumberOfGPSSat;
     339      }
     340      else if (prn[0] == 'R') {
     341        sd = co.Sat + CLOCKORBIT_NUMGPS + co.NumberOfGLONASSSat;
     342        ++co.NumberOfGLONASSSat;
     343      }
     344
     345      processSatellite(GPSweek, GPSweeks, prn, xx, sd);
     346    }
     347
     348    if (_outSocket) {
     349      char obuffer[CLOCKORBIT_BUFFERSIZE];
     350      int len = MakeClockOrbit(&co, COTYPE_AUTO, 0, obuffer, sizeof(obuffer));
     351      if (len > 0) {
     352        _outSocket->write(obuffer, len);
     353        _outSocket->flush();
     354      }
     355    }
     356  }
     357}
     358
     359//
     360////////////////////////////////////////////////////////////////////////////
     361void t_bns::processSatellite(int GPSweek, double GPSweeks, const QString& prn,
     362                             const ColumnVector& xx,
     363                             struct ClockOrbit::SatData* sd) {
     364
     365  // No broadcast ephemeris available
     366  // --------------------------------
     367  if ( !_ephList.contains(prn) ) {
     368    return;
     369  }
     370
     371  t_ephPair* pair = _ephList[prn];
     372  gpsEph*    ep   = pair->eph;
     373
     374  ColumnVector xB(4);
     375  ColumnVector vv(3);
     376
     377  satellitePosition(GPSweek, GPSweeks, ep, xB(1), xB(2), xB(3), xB(4),
     378                    vv(1), vv(2), vv(3));
     379
     380  ColumnVector dx   = xx.Rows(1,3) - xB.Rows(1,3);
     381  double       dClk = (xx(4) - xB(4)) * 299792458.0;
     382  ColumnVector rsw(3);
     383
     384  XYZ_to_RSW(xB.Rows(1,3), vv, dx, rsw);
     385
     386  if (sd) {
     387    sd->ID                    = prn.mid(1).toInt();
    379388    sd->IOD                   = int(ep->IODE);
    380389    sd->Clock.DeltaA0         = dClk;
     
    382391    sd->Orbit.DeltaAlongTrack = rsw(2);
    383392    sd->Orbit.DeltaCrossTrack = rsw(3);
    384 
    385     char obuffer[CLOCKORBIT_BUFFERSIZE];
    386     int len = MakeClockOrbit(&co, COTYPE_AUTO, 0, obuffer, sizeof(obuffer));
    387     if (len > 0) {
    388       _outSocket->write(obuffer, len);
    389       _outSocket->flush();
    390     }
     393  }
     394
     395  if (_outStream) {
     396    QString line;
     397    line.sprintf("%d %.1f %s   %3d %3d   %8.3f   %8.3f %8.3f %8.3f\n",
     398                 GPSweek, GPSweeks, ep->prn.toAscii().data(),
     399                 int(ep->IODC), int(ep->IODE), dClk, rsw(1), rsw(2), rsw(3));
     400     *_outStream << line;
     401    _outStream->flush();
    391402  }
    392403  if (_rnx) {
  • trunk/BNS/bns.h

    r858 r863  
    88
    99#include "bnseph.h"
     10extern "C" {
     11#include "RTCM/clock_orbit_rtcm.h"
     12}
    1013
    1114class bnsRinex;
     
    5255  void readEpoch();
    5356  void processSatellite(int GPSweek, double GPSweeks, const QString& prn,
    54                         const ColumnVector& xx);
     57                        const ColumnVector& xx, struct ClockOrbit::SatData* sd);
    5558
    5659  QTcpServer*               _clkServer;
Note: See TracChangeset for help on using the changeset viewer.