Index: trunk/BNC/src/bnccore.cpp
===================================================================
--- trunk/BNC/src/bnccore.cpp	(revision 6383)
+++ trunk/BNC/src/bnccore.cpp	(revision 6384)
@@ -93,4 +93,7 @@
     _galileoEph[ii-PRN_GALILEO_START] = 0;
   }
+  for (int ii = PRN_SBAS_START; ii <= PRN_SBAS_END; ii++) {
+    _sbasEph[ii-PRN_SBAS_START] = 0;
+  }
 
   // Eph file(s)
@@ -103,4 +106,6 @@
   _ephFileGalileo   = 0;
   _ephStreamGalileo = 0;
+  _ephFileSBAS      = 0;
+  _ephStreamSBAS    = 0;
 
   _port    = 0;
@@ -155,4 +160,7 @@
   for (int ii = PRN_GALILEO_START; ii <= PRN_GALILEO_END; ii++) {
     delete _galileoEph[ii-PRN_GALILEO_START];
+  }
+  for (int ii = PRN_SBAS_START; ii <= PRN_SBAS_END; ii++) {
+    delete _sbasEph[ii-PRN_SBAS_START];
   }
 
@@ -403,4 +411,8 @@
       _galileoEph[ii-PRN_GALILEO_START] = 0;
     }
+    for (int ii = PRN_SBAS_START; ii <= PRN_SBAS_END; ii++) {
+      delete _sbasEph[ii-PRN_SBAS_START];
+      _sbasEph[ii-PRN_SBAS_START] = 0;
+    }
 
     delete _ephStreamGPS;
@@ -409,5 +421,4 @@
     QFlags<QIODevice::OpenModeFlag> appendFlagGPS;
     QFlags<QIODevice::OpenModeFlag> appendFlagGlonass;
-    QFlags<QIODevice::OpenModeFlag> appendFlagGalileo;
 
     if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked &&
@@ -426,4 +437,6 @@
       _ephFileGalileo   = _ephFileGPS;
       _ephStreamGalileo = _ephStreamGPS;
+      _ephFileSBAS      = _ephFileGPS;
+      _ephStreamSBAS    = _ephStreamGPS;
     }
     else if (_rinexVers == 2) {
@@ -814,4 +827,50 @@
   QMutexLocker locker(&_mutex);
 
-  qDebug() << "t_bncCore::slotNewSBASEph";
-}
+  // Check wrong Ephemerides
+  // -----------------------
+  if (sbaseph->x_pos == 0.0 && 
+      sbaseph->y_pos == 0.0 && 
+      sbaseph->z_pos == 0.0) {
+    delete sbaseph;
+    return;
+  } 
+
+  sbasephemeris copy_sbaseph = *sbaseph;
+  emit newEphSBAS(copy_sbaseph);
+
+  printEphHeader();
+
+  sbasephemeris** ee = &_sbasEph[sbaseph->satellite - PRN_SBAS_START];
+
+  bool replace = false;
+  if (*ee != 0) {
+    bncTime oldTime((*ee)->GPSweek_TOE,   double((*ee)->TOE));
+    bncTime newTime(sbaseph->GPSweek_TOE, double(sbaseph->TOE));
+    if (newTime > oldTime) {
+      replace = true;
+    }
+  }
+
+  if ( *ee == 0 || replace) {
+    delete *ee;
+    *ee = sbaseph;
+    printSBASEph(sbaseph, true);
+  }
+  else {
+    printSBASEph(sbaseph, false);
+    delete sbaseph;
+  }
+}
+
+// Print One SBAS Ephemeris
+////////////////////////////////////////////////////////////////////////////
+void t_bncCore::printSBASEph(sbasephemeris* ep, bool printFile) {
+
+  t_ephSBAS eph;
+  eph.set(ep);
+
+  QString strV2 = eph.toString(t_rnxNavFile::defaultRnxNavVersion2);
+  QString strV3 = eph.toString(t_rnxObsHeader::defaultRnxObsVersion3);
+
+  printOutput(printFile, _ephStreamSBAS, strV2, strV3);
+}
Index: trunk/BNC/src/bnccore.h
===================================================================
--- trunk/BNC/src/bnccore.h	(revision 6383)
+++ trunk/BNC/src/bnccore.h	(revision 6384)
@@ -89,4 +89,5 @@
   void newEphGlonass(glonassephemeris glonasseph);
   void newEphGalileo(galileoephemeris galileoeph);
+  void newEphSBAS(sbasephemeris sbaseph);
   void newOrbCorrections(QList<t_orbCorr> orbCorr);
   void newClkCorrections(QList<t_clkCorr> clkCorr);
@@ -108,4 +109,5 @@
   void printGlonassEph(glonassephemeris* ep, bool printFile, const QString& staID);
   void printGalileoEph(galileoephemeris* ep, bool printFile);
+  void printSBASEph(sbasephemeris* ep, bool printFile);
   void printOutput(bool printFile, QTextStream* stream, 
                    const QString& strV2, const QString& strV3);
@@ -128,8 +130,11 @@
   QFile*                 _ephFileGalileo;
   QTextStream*           _ephStreamGalileo;
+  QFile*                 _ephFileSBAS;
+  QTextStream*           _ephStreamSBAS;
   gpsephemeris*          _gpsEph[PRN_GPS_END - PRN_GPS_START + 1];
   gpsephemeris*          _qzssEph[PRN_QZSS_END - PRN_QZSS_START + 1];
   glonassephemeris*      _glonassEph[PRN_GLONASS_END - PRN_GLONASS_START + 1];
   galileoephemeris*      _galileoEph[PRN_GALILEO_END - PRN_GALILEO_START + 1];
+  sbasephemeris*         _sbasEph[PRN_SBAS_END - PRN_SBAS_START + 1];
   QString                _userName;
   QString                _pgmName;
