Index: /trunk/BNC/src/PPP/pppClient.cpp
===================================================================
--- /trunk/BNC/src/PPP/pppClient.cpp	(revision 6652)
+++ /trunk/BNC/src/PPP/pppClient.cpp	(revision 6653)
@@ -336,4 +336,8 @@
     copy(&_filter->Q().data()[0], &_filter->Q().data()[6], _output->_covMatrix);
 
+    _output->_trp0     = t_tropo::delay_saast(_staRover->xyzApr(), M_PI/2.0);
+    _output->_trp      = _filter->trp();
+    _output->_trpStdev = _filter->trpStdev();
+
     _output->_numSat     = _filter->numSat();
     _output->_pDop       = _filter->PDOP();
Index: /trunk/BNC/src/PPP/pppFilter.h
===================================================================
--- /trunk/BNC/src/PPP/pppFilter.h	(revision 6652)
+++ /trunk/BNC/src/PPP/pppFilter.h	(revision 6653)
@@ -28,4 +28,22 @@
   double PDOP() const {return _dop.P;}
   double GDOP() const {return _dop.G;}
+  double trp() const {
+    const std::vector<t_pppParam*>& par = _parlist->params();
+    for (unsigned ii = 0; ii < par.size(); ++ii) {
+      if (par[ii]->type() == t_pppParam::trp) {
+        return x()[ii];
+      }
+    }
+    return 0.0;
+  };
+  double trpStdev() const {
+    const std::vector<t_pppParam*>& par = _parlist->params();
+    for (unsigned ii = 0; ii < par.size(); ++ii) {
+      if (par[ii]->type() == t_pppParam::trp) {
+        return sqrt(Q()[ii][ii]);
+      }
+    }
+    return 0.0;
+  };
 
  private:
@@ -50,4 +68,5 @@
     double G;
   };
+
   t_irc processSystem(const std::vector<t_lc::type>& LCs, 
                       const std::vector<t_pppSatObs*>& obsVector);
@@ -60,4 +79,6 @@
 
   void cmpDOP(const std::vector<t_pppSatObs*>& obsVector);
+
+  void getTrp(void);
 
   void predictCovCrdPart(const SymmetricMatrix& QFltOld);
Index: /trunk/BNC/src/PPP_free/pppClient.cpp
===================================================================
--- /trunk/BNC/src/PPP_free/pppClient.cpp	(revision 6652)
+++ /trunk/BNC/src/PPP_free/pppClient.cpp	(revision 6653)
@@ -145,4 +145,6 @@
     output->_numSat      = _filter->numSat();
     output->_pDop        = _filter->PDOP();
+    output->_trp0        = _filter->delay_saast(M_PI/2.0);
+    output->_trp         = _filter->trp();
   }
   else {
Index: /trunk/BNC/src/PPP_free/pppFilter.h
===================================================================
--- /trunk/BNC/src/PPP_free/pppFilter.h	(revision 6652)
+++ /trunk/BNC/src/PPP_free/pppFilter.h	(revision 6653)
@@ -169,4 +169,13 @@
     return 0.0;
   }
+  double trpStdev() const {
+    for (unsigned ii = 0; ii < _params.size(); ++ii) {
+      t_pppParam* pp = _params[ii];
+      if (pp->type() == t_pppParam::TROPO) {
+        return sqrt(Q()[ii][ii]);
+      }
+    }
+    return 0.0;
+  }
   double Glonass_offset() const {
     for (int ii = 0; ii < _params.size(); ++ii) {
Index: /trunk/BNC/src/bncsinextro.cpp
===================================================================
--- /trunk/BNC/src/bncsinextro.cpp	(revision 6653)
+++ /trunk/BNC/src/bncsinextro.cpp	(revision 6653)
@@ -0,0 +1,134 @@
+
+/* -------------------------------------------------------------------------
+ * BKG NTRIP Server
+ * -------------------------------------------------------------------------
+ *
+ * Class:      bncSinexTro
+ *
+ * Purpose:    writes SINEX TRO files
+ *
+ * Author:     A. Stürze
+ *
+ * Created:    19-Feb-2015
+ *
+ * Changes:
+ *
+ * -----------------------------------------------------------------------*/
+
+#include <math.h>
+#include <iomanip>
+
+#include "bncsinextro.h"
+
+using namespace BNC_PPP;
+using namespace std;
+
+// Constructor
+////////////////////////////////////////////////////////////////////////////
+bncSinexTro::bncSinexTro(const t_pppOptions* opt,
+                         const QString& sklFileName, const QString& intr,
+                         int sampl)
+  : bncoutf(sklFileName, intr, sampl) {
+  _opt       = opt;
+  (!sampl) ? _sampl = 1 : _sampl =  sampl;
+}
+
+// Destructor
+////////////////////////////////////////////////////////////////////////////
+bncSinexTro::~bncSinexTro() {
+  closeFile();
+}
+
+// Write Header
+////////////////////////////////////////////////////////////////////////////
+void bncSinexTro::writeHeader(const QDateTime& datTim) {
+  int    GPSWeek;
+  double GPSWeeks;
+  GPSweekFromDateAndTime(datTim, GPSWeek, GPSWeeks);
+  int daysec    = int(fmod(GPSWeeks, 86400.0));
+  int dayOfYear = datTim.date().dayOfYear();
+  QString yy    = datTim.toString("yy");
+
+  QString creationTime = QString("%1:%2:%3").arg(yy)
+                                            .arg(dayOfYear, 3, 10, QLatin1Char('0'))
+                                            .arg(daysec   , 5, 10, QLatin1Char('0'));
+  QString startTime = creationTime;
+  QString endTime = QString("%1:%2:%3").arg(yy)
+                                       .arg(dayOfYear, 3, 10, QLatin1Char('0'))
+                                       .arg(84600    , 5, 10);
+
+
+  _out << "%=TRO 0.01 BNC " << creationTime.toStdString() << " BNC "
+       << startTime.toStdString() << " " << endTime.toStdString() << " P "
+       << _opt->_roverName.substr(0,4)   << endl;
+
+
+  _out << "+FILE/REFERENCE" << endl;
+  _out << " DESCRIPTION        " << "BNC generated SINEX TRO file" << endl;
+  _out << " OUTPUT             " << "Total Troposphere Zenith Path Delay Product" << endl;
+  _out << " SOFTWARE           " << BNCPGMNAME <<  endl;
+  _out << " HARDWARE           " << BNC_OS << endl;
+  _out << " INPUT              " << "Orbit and Clock information used from BRDC and RTCM-SSR streams" << endl;
+  _out << "-FILE/REFERENCE" << endl << endl;
+
+
+  _out << "+TROP/DESCRIPTION" << endl;
+  _out << "*KEYWORD______________________ VALUE(S)______________" << endl;
+  _out << " SAMPLING INTERVAL                                " << _sampl << endl;
+  _out << " SAMPLING TROP                                    " << _sampl << endl;
+  _out << " ELEVATION CUTOFF ANGLE                           "
+       << setprecision(1) << _opt->_minEle * 180.0/M_PI << endl;
+  _out << " TROP MAPPING FUNCTION         " << "Saastamoinen" << endl;
+  _out << " SOLUTION_FIELDS_1             " << "TROTOT STDEV" << endl;
+  _out << "-TROP/DESCRIPTION"<< endl << endl;
+
+
+  _out << "+TROP/STA_COORDINATES" << endl;
+  _out << "*SITE PT SOLN T STA_X_______ STA_Y_______ STA_Z_______ SYSTEM REMARK" << endl;
+  _out << " " << _opt->_roverName.substr(0,4) << "  A    1 P "
+       << setw(12) << setprecision(3) << _opt->_xyzAprRover(1) << " "
+       << setw(12) << setprecision(3) << _opt->_xyzAprRover(2) << " "
+       << setw(12) << setprecision(3) << _opt->_xyzAprRover(3) << " ITRF08" << endl;
+  _out << "-TROP/STA_COORDINATES"  << endl << endl;
+
+
+  _out << "+TROP/SOLUTION" << endl;
+  _out << "*SITE EPOCH_______ TROTOT STDEV" << endl;
+}
+
+// Write One Epoch
+////////////////////////////////////////////////////////////////////////////
+t_irc bncSinexTro::write(QByteArray staID, int GPSWeek, double GPSWeeks,
+    double trotot, double stdev) {
+
+  QDateTime datTim = dateAndTimeFromGPSweek(GPSWeek, GPSWeeks);
+  int daysec    = int(fmod(GPSWeeks, 86400.0));
+  int dayOfYear = datTim.date().dayOfYear();
+  QString yy    = datTim.toString("yy");
+  QString time  = QString("%1:%2:%3").arg(yy)
+                                     .arg(dayOfYear, 3, 10, QLatin1Char('0'))
+                                     .arg(daysec   , 5, 10, QLatin1Char('0'));
+
+  if ((reopen(GPSWeek, GPSWeeks) == success) &&
+      (fmod(daysec, double(_sampl)) == 0.0)) {
+    _out << ' '  << staID.left(4).data() << ' ' << time.toStdString() << ' '
+         << noshowpos << setw(6) << setprecision(1) << trotot * 1000.0
+         << noshowpos << setw(6) << setprecision(1) << stdev  * 1000.0 << endl;
+    _out.flush();
+    return success;
+  }  else {
+    return failure;
+  }
+}
+
+// Close File (write last lines)
+////////////////////////////////////////////////////////////////////////////
+void bncSinexTro::closeFile() {
+  _out << "-TROP/SOLUTION" << endl;
+  _out << "%=ENDTROP" << endl;
+  bncoutf::closeFile();
+}
+
+
+
+
Index: /trunk/BNC/src/bncsinextro.h
===================================================================
--- /trunk/BNC/src/bncsinextro.h	(revision 6653)
+++ /trunk/BNC/src/bncsinextro.h	(revision 6653)
@@ -0,0 +1,33 @@
+#ifndef BNCSINEXTRO_H
+#define BNCSINEXTRO_H
+
+
+#include <fstream>
+#include <newmat.h>
+#include <QtCore>
+
+#include "bncoutf.h"
+#include "bncversion.h"
+#include "pppOptions.h"
+
+using namespace BNC_PPP;
+
+class bncSinexTro : public bncoutf {
+ public:
+  bncSinexTro(const t_pppOptions* opt,
+              const QString& sklFileName, const QString& intr,
+              int sampl);
+  virtual ~bncSinexTro();
+  virtual t_irc write(QByteArray staID, int GPSWeek, double GPSWeeks,
+                      double trotot, double stdev);
+
+ private:
+  virtual void writeHeader(const QDateTime& datTim);
+  virtual void closeFile();
+  QString _roverName;
+  int     _sampl;
+  const t_pppOptions*  _opt;
+};
+
+
+#endif
Index: /trunk/BNC/src/pppInclude.h
===================================================================
--- /trunk/BNC/src/pppInclude.h	(revision 6652)
+++ /trunk/BNC/src/pppInclude.h	(revision 6653)
@@ -31,4 +31,7 @@
   double       _covMatrix[6]; 
   double       _neu[3];  
+  double       _trp0;
+  double       _trp;
+  double       _trpStdev;
   int          _numSat;       
   double       _pDop;         
Index: /trunk/BNC/src/pppRun.cpp
===================================================================
--- /trunk/BNC/src/pppRun.cpp	(revision 6652)
+++ /trunk/BNC/src/pppRun.cpp	(revision 6653)
@@ -53,4 +53,5 @@
 #include "bncsettings.h"
 #include "bncoutf.h"
+#include "bncsinextro.h"
 #include "rinex/rnxobsfile.h"
 #include "rinex/rnxnavfile.h"
@@ -159,7 +160,8 @@
     }
     else {
-      snxtroFileSkl.replace("${STATION}", roverName);
-    }
-    _snxtroFile = new bncoutf(snxtroFileSkl, "1 day", 0);
+      snxtroFileSkl.replace("${STATION}", roverName.left(4));
+    }
+    int samplSnxTro = settings.value("PPP/snxtroSampl").toInt();
+    _snxtroFile = new bncSinexTro(_opt, snxtroFileSkl, "1 day", samplSnxTro);
   }
 }
@@ -272,7 +274,9 @@
           << " Y = "  << setprecision(4) << output._xyzRover[1]
           << " Z = "  << setprecision(4) << output._xyzRover[2]
-          << " NEU: " << setprecision(4) << output._neu[0]     
-          << " " << setprecision(4) << output._neu[1]     
-          << " " << setprecision(4) << output._neu[2];
+          << " NEU: " << showpos << setw(8) << setprecision(4) << output._neu[0]
+          << " "      << showpos << setw(8) << setprecision(4) << output._neu[1]
+          << " "      << showpos << setw(8) << setprecision(4) << output._neu[2]
+          << " TRP: " << showpos << setw(8) << setprecision(4) << output._trp0
+          << " "      << showpos << setw(8) << setprecision(4) << output._trp;
     }
 
@@ -294,5 +298,6 @@
 
     if (_snxtroFile && output._epoTime.valid()) {
-     // _snxtroFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(),QString("TEST"));
+      _snxtroFile->write(staID, int(output._epoTime.gpsw()), output._epoTime.gpssec(),
+                  output._trp0 + output._trp, output._trpStdev);
     }
 
Index: /trunk/BNC/src/pppRun.h
===================================================================
--- /trunk/BNC/src/pppRun.h	(revision 6652)
+++ /trunk/BNC/src/pppRun.h	(revision 6653)
@@ -14,4 +14,5 @@
 class t_corrFile;
 class bncoutf;
+class bncSinexTro;
 
 namespace BNC_PPP {
@@ -72,5 +73,5 @@
   bncoutf*               _logFile;
   bncoutf*               _nmeaFile;
-  bncoutf*               _snxtroFile;
+  bncSinexTro*           _snxtroFile;
 };
 
Index: /trunk/BNC/src/pppWidgets.cpp
===================================================================
--- /trunk/BNC/src/pppWidgets.cpp	(revision 6652)
+++ /trunk/BNC/src/pppWidgets.cpp	(revision 6653)
@@ -213,4 +213,5 @@
   _minEle->setValue(settings.value(_minEle->objectName()).toInt());
   _corrWaitTime->setValue(settings.value(_corrWaitTime->objectName()).toInt());
+  _snxtroSampl->setValue(settings.value(_snxtroSampl->objectName()).toInt());
 
   // Table with stations
@@ -264,4 +265,5 @@
   settings.setValue(_nmeaPort    ->objectName(), _nmeaPort    ->text());
   settings.setValue(_snxtroFile  ->objectName(), _snxtroFile  ->text());
+  settings.setValue(_snxtroSampl ->objectName(), _snxtroSampl ->value());
   settings.setValue(_lcGPS       ->objectName(), _lcGPS       ->currentText());
   settings.setValue(_lcGLONASS   ->objectName(), _lcGLONASS   ->currentText());
