Index: trunk/BNC/src/bncwindow.cpp
===================================================================
--- trunk/BNC/src/bncwindow.cpp	(revision 9634)
+++ trunk/BNC/src/bncwindow.cpp	(revision 9635)
@@ -496,5 +496,5 @@
   _cmbMethodComboBox = new QComboBox();
   _cmbMethodComboBox->setEditable(false);
-  _cmbMethodComboBox->addItems(QString("Filter,Single-Epoch").split(","));
+  _cmbMethodComboBox->addItems(QString("Kalman Filter,Single-Epoch").split(","));
   int im = _cmbMethodComboBox->findText(settings.value("cmbMethod").toString());
   if (im != -1) {
@@ -536,8 +536,11 @@
   connect(_cmbIrnssCheckBox, SIGNAL(stateChanged(int)), this, SLOT(slotBncTextChanged()));
 
+  _cmbBsxFile      = new qtFileChooser(0, qtFileChooser::File);
+  _cmbBsxFile->setFileName(settings.value("cmbBsxFile").toString());
+
   // Upload Results
   // -------------
-  _uploadTable = new QTableWidget(0,15);
-  _uploadTable->setHorizontalHeaderLabels(QString("Host, Port, Mount, Ntrip, User, Password, System, Format, CoM, SP3 File, RNX File, PID, SID, IOD, bytes").split(","));
+  _uploadTable = new QTableWidget(0,16);
+  _uploadTable->setHorizontalHeaderLabels(QString("Host, Port, Mount, Ntrip, User, Password, System, Format, CoM, SP3 File, RNX File, BSX File, PID, SID, IOD, bytes").split(","));
   _uploadTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
   _uploadTable->setSelectionBehavior(QAbstractItemView::SelectRows);
@@ -553,8 +556,9 @@
   _uploadTable->horizontalHeader()->resizeSection( 9,15*ww);
   _uploadTable->horizontalHeader()->resizeSection(10,15*ww);
-  _uploadTable->horizontalHeader()->resizeSection(11, 4*ww);
+  _uploadTable->horizontalHeader()->resizeSection(11,15*ww);
   _uploadTable->horizontalHeader()->resizeSection(12, 4*ww);
   _uploadTable->horizontalHeader()->resizeSection(13, 4*ww);
-  _uploadTable->horizontalHeader()->resizeSection(14,12*ww);
+  _uploadTable->horizontalHeader()->resizeSection(14, 4*ww);
+  _uploadTable->horizontalHeader()->resizeSection(15,12*ww);
 #if QT_VERSION < 0x050000
   _uploadTable->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
@@ -606,4 +610,12 @@
   _uploadSamplClkRnxSpinBox->setSuffix(" sec");
 
+  _uploadSamplBiaSnxSpinBox = new QSpinBox;
+  _uploadSamplBiaSnxSpinBox->setMinimum(0);
+  _uploadSamplBiaSnxSpinBox->setMaximum(60);
+  _uploadSamplBiaSnxSpinBox->setSingleStep(5);
+  _uploadSamplBiaSnxSpinBox->setMaximumWidth(9*ww);
+  _uploadSamplBiaSnxSpinBox->setValue(settings.value("uploadSamplBiaSnx").toInt());
+  _uploadSamplBiaSnxSpinBox->setSuffix(" sec");
+
   int iRowT = _uploadTable->rowCount();
   if (iRowT > 0) {
@@ -612,4 +624,5 @@
     enableWidget(true, _uploadSamplSp3SpinBox);
     enableWidget(true, _uploadSamplClkRnxSpinBox);
+    enableWidget(true, _uploadSamplBiaSnxSpinBox);
     enableWidget(true, _uploadAntexFile);
   }
@@ -619,4 +632,5 @@
     enableWidget(false, _uploadSamplSp3SpinBox);
     enableWidget(false, _uploadSamplClkRnxSpinBox);
+    enableWidget(true, _uploadSamplBiaSnxSpinBox);
     enableWidget(false, _uploadAntexFile);
   }
@@ -1240,31 +1254,32 @@
 
   populateCmbTable();
-  cmbLayout->addWidget(_cmbTable,                                            0, 0, 8, 3);
+  cmbLayout->addWidget(_cmbTable,                                                0, 0, 8, 6);
   cmbLayout->addWidget(new QLabel(" Combine Broadcast Correction streams.<br>"), 1, 6, 1, 10);
-  cmbLayout->addWidget(addCmbRowButton,                                      2,  6);
-  cmbLayout->addWidget(delCmbRowButton,                                      2,  7);
-  cmbLayout->addWidget(new QLabel("Method"),                                 3,  6, Qt::AlignRight);
-  cmbLayout->addWidget(_cmbMethodComboBox,                                   3,  7);
-  cmbLayout->addWidget(new QLabel(" Maximal residuum"),                      4,  6, Qt::AlignRight);
-  cmbLayout->addWidget(_cmbMaxresLineEdit,                                   4,  7, Qt::AlignRight);
-  cmbLayout->addWidget(new QLabel("Sampling"),                               5,  6, Qt::AlignRight);
-  cmbLayout->addWidget(_cmbSamplSpinBox,                                     5,  7);
-  cmbLayout->addWidget(new QLabel("GNSS"),                                   6,  6, Qt::AlignRight);
-  cmbLayout->addWidget(new QLabel("Systems"),                                6,  7, Qt::AlignLeft);
-  cmbLayout->addWidget(new QLabel("GPS (1W/2W)"),                            6,  8);
-  cmbLayout->addWidget(_cmbGpsCheckBox,                                      6,  9);
-  cmbLayout->addWidget(new QLabel("GLO (1P/2P)"),                            6, 10);
-  cmbLayout->addWidget(_cmbGloCheckBox,                                      6, 11);
-  cmbLayout->addWidget(new QLabel("Galileo (1C/5Q)"),                        6, 12);
-  cmbLayout->addWidget(_cmbGalCheckBox,                                      6, 13);
-  cmbLayout->addWidget(new QLabel("Beidou (2I/6I)"),                         6, 14);
-  cmbLayout->addWidget(_cmbBdsCheckBox,                                      6, 15);
-  cmbLayout->addWidget(new QLabel("QZSS (1C/2L)"),                           7,  8);
-  cmbLayout->addWidget(_cmbQzssCheckBox,                                     7,  9);
-  cmbLayout->addWidget(new QLabel("SBAS (1C/5Q)"),                           7, 10);
-  cmbLayout->addWidget(_cmbSbasCheckBox,                                     7, 11);
-  cmbLayout->addWidget(new QLabel("IRNSS"),                                  7, 12);
-  cmbLayout->addWidget(_cmbIrnssCheckBox,                                    7, 13);
-  cmbLayout->setRowStretch(6, 999);
+  cmbLayout->addWidget(addCmbRowButton,                                          2,  6);
+  cmbLayout->addWidget(delCmbRowButton,                                          2,  7);
+  cmbLayout->addWidget(new QLabel("Method"),                                     3,  6, Qt::AlignLeft);
+  cmbLayout->addWidget(_cmbMethodComboBox,                                       3,  7);
+  cmbLayout->addWidget(new QLabel("BSX File"),                                   4,  6, Qt::AlignLeft);
+  cmbLayout->addWidget(_cmbBsxFile,                                              4,  7, Qt::AlignRight);
+  cmbLayout->addWidget(new QLabel("Max Residual"),                               5,  6, Qt::AlignLeft);
+  cmbLayout->addWidget(_cmbMaxresLineEdit,                                       5,  7, Qt::AlignRight);
+  cmbLayout->addWidget(new QLabel("Sampling"),                                   6,  6, Qt::AlignLeft);
+  cmbLayout->addWidget(_cmbSamplSpinBox,                                         6,  7, Qt::AlignRight);
+  cmbLayout->addWidget(new QLabel("GNSS"),                                       7,  6, Qt::AlignLeft);
+  cmbLayout->addWidget(new QLabel("GPS (1W/2W)"),                                7,  7);
+  cmbLayout->addWidget(_cmbGpsCheckBox,                                          7,  8);
+  cmbLayout->addWidget(new QLabel("GLONASS (1P/2P)"),                            7,  9);
+  cmbLayout->addWidget(_cmbGloCheckBox,                                          7, 10);
+  cmbLayout->addWidget(new QLabel("Galileo (1C/5Q)"),                            7, 11);
+  cmbLayout->addWidget(_cmbGalCheckBox,                                          7, 12);
+  cmbLayout->addWidget(new QLabel("Beidou (2I/6I)"),                             7, 13);
+  cmbLayout->addWidget(_cmbBdsCheckBox,                                          7, 14);
+  cmbLayout->addWidget(new QLabel("QZSS (1C/2L)"),                               8,  7);
+  cmbLayout->addWidget(_cmbQzssCheckBox,                                         8,  8);
+  cmbLayout->addWidget(new QLabel("SBAS (1C/5Q)"),                               8,  9);
+  cmbLayout->addWidget(_cmbSbasCheckBox,                                         8, 10);
+  cmbLayout->addWidget(new QLabel("IRNSS"),                                      8, 11);
+  cmbLayout->addWidget(_cmbIrnssCheckBox,                                        8, 12);
+  cmbLayout->setRowStretch(8, 999);
 
   connect(addCmbRowButton, SIGNAL(clicked()), this, SLOT(slotAddCmbRow()));
@@ -1291,5 +1306,7 @@
   uploadHlpLayout->addWidget(new QLabel("RNX"),                   0, 8, Qt::AlignRight);
   uploadHlpLayout->addWidget(_uploadSamplClkRnxSpinBox,           0, 9);
-  uploadHlpLayout->addWidget(setUploadTrafoButton,                0,10);
+  uploadHlpLayout->addWidget(new QLabel("BSX"),                   0,10, Qt::AlignRight);
+  uploadHlpLayout->addWidget(_uploadSamplBiaSnxSpinBox,           0,11);
+  uploadHlpLayout->addWidget(setUploadTrafoButton,                0,12);
   uploadHlpLayout->addWidget(new QLabel("ANTEX file"),            1, 0, Qt::AlignLeft);
   uploadHlpLayout->addWidget(_uploadAntexFile,                    1, 1, 1, 4);
@@ -1479,11 +1496,12 @@
   _cmbMaxresLineEdit->setWhatsThis(tr("<p>BNC combines all incoming clocks according to specified weights. Individual clock estimates that differ by more than 'Maximal residuum' meters from the average of all clocks will be ignored.<p></p>It is suggested to specify a value of about 0.2 m for the Kalman filter combination approach and a value of about 3.0 meters for the Single-Epoch combination approach.</p><p>Default is a value of '999.0'. <i>[key: cmbMaxres]</i></p>"));
   _cmbSamplSpinBox->setWhatsThis(tr("<p>Select a combination Sampling interval for the clocks. Clock corrections will be produced following that interval.</p><p>A value of 10 sec may be an appropriate choice. <i>[key: cmbSampl]</i></p>"));
-  _cmbGpsCheckBox->setWhatsThis(tr("<p>GPS corrections shall be combined. <i>[key: cmbGps]</i></p>"));
-  _cmbGloCheckBox->setWhatsThis(tr("<p>GLONASS corrections shall be combined; GPS Broadcast ephemeris and corrections are required. <i>[key: cmbGlo]</i></p>"));
-  _cmbGalCheckBox->setWhatsThis(tr("<p>Galileo corrections shall be combined; GLONASS Broadcast ephemeris and corrections are required. <i>[key: cmbGal]</i></p>"));
-  _cmbBdsCheckBox->setWhatsThis(tr("<p>Beidou corrections shall be combined; Galileo Broadcast ephemeris and corrections are required. <i>[key: cmbBds]</i></p>"));
-  _cmbQzssCheckBox->setWhatsThis(tr("<p>QZSS corrections shall be combined; QZSS Broadcast ephemeris and corrections are required. <i>[key: cmbQzss]</i></p>"));
-  _cmbSbasCheckBox->setWhatsThis(tr("<p>SBAS corrections shall be combined; SBAS Broadcast ephemeris and corrections are required. <i>[key: cmbSbas]</i></p>"));
-  _cmbIrnssCheckBox->setWhatsThis(tr("<p>IRNSS corrections shall be combined; IRNSS Broadcast ephemeris and corrections are required. <i>[key: cmbIrnss]</i></p>"));
+  _cmbGpsCheckBox->setWhatsThis(tr("<p>GPS clock corrections shall be combined. <i>[key: cmbGps]</i></p>"));
+  _cmbGloCheckBox->setWhatsThis(tr("<p>GLONASS clock corrections shall be combined; GPS Broadcast ephemeris and corrections are required. <i>[key: cmbGlo]</i></p>"));
+  _cmbGalCheckBox->setWhatsThis(tr("<p>Galileo clock corrections shall be combined; GLONASS Broadcast ephemeris and corrections are required. <i>[key: cmbGal]</i></p>"));
+  _cmbBdsCheckBox->setWhatsThis(tr("<p>Beidou clock corrections shall be combined; Galileo Broadcast ephemeris and corrections are required. <i>[key: cmbBds]</i></p>"));
+  _cmbQzssCheckBox->setWhatsThis(tr("<p>QZSS clock corrections shall be combined; QZSS Broadcast ephemeris and corrections are required. <i>[key: cmbQzss]</i></p>"));
+  _cmbSbasCheckBox->setWhatsThis(tr("<p>SBAS clock corrections shall be combined; SBAS Broadcast ephemeris and corrections are required. <i>[key: cmbSbas]</i></p>"));
+  _cmbIrnssCheckBox->setWhatsThis(tr("<p>IRNSS clock corrections shall be combined; IRNSS Broadcast ephemeris and corrections are required. <i>[key: cmbIrnss]</i></p>"));
+  _cmbBsxFile->setWhatsThis(tr("<p> Specify a Bias SINEX File that will be used to add satellite code biases to the combined clocks. <i>[key: cmbBsxFile]</i></p>"));
 
   // WhatsThis, Upload Corrections
@@ -1496,4 +1514,5 @@
   _uploadSamplSp3SpinBox->setWhatsThis(tr("<p>Select a SP3 orbit file sampling interval in minutes.</p><p>A value of zero '0' tells BNC to store all available samples into SP3 orbit files. <i>[key: uploadSamplSp3]</i></p>"));
   _uploadSamplClkRnxSpinBox->setWhatsThis(tr("<p>Select a Clock RINEX file sampling interval in seconds.</p><p>A value of zero '0' tells BNC to store all available samples into Clock RINEX files. <i>[key: uploadSamplClkRnx]</i></p>"));
+  _uploadSamplBiaSnxSpinBox->setWhatsThis(tr("<p>Select a Bias SINEX file sampling interval in seconds.</p><p>A value of zero '0' tells BNC to store all available samples into Bias SINEX files. <i>[key: uploadSamplBiaSnx]</i></p>"));
   setUploadTrafoButton->setWhatsThis(tr("<p>Hit 'Custom Trafo' to specify your own 14 parameter Helmert Transformation instead of selecting a predefined transformation via option 'System'.</p>"));
   _uploadAntexFile->setWhatsThis(tr("<p>When producing SP3 files or referring orbit and clock corrections to the satellite's Center of Mass (CoM) instead Antenna Phase Center (APC), an offset has to be applied which is available from the IGS 'ANTEX file'. You must therefore specify an 'ANTEX file' path if you want to save the stream content in SP3 format and/or refer correctors to CoM.</p><p>If you don't specify an 'ANTEX file' path, the SP3 file content as well as the orbit and clock correctors will be referred to satellite APCs. <i>[key: uploadAntexFile]</i></p>"));
@@ -1622,4 +1641,5 @@
   delete _cmbSbasCheckBox;
   delete _cmbIrnssCheckBox;
+  delete _cmbBsxFile;
   _uploadEphTable->deleteLater();
   delete _uploadSamplRtcmEphCorrSpinBox;
@@ -1630,4 +1650,5 @@
   delete _uploadSamplSp3SpinBox;
   delete _uploadSamplClkRnxSpinBox;
+  delete _uploadSamplBiaSnxSpinBox;
   delete _reqcActionComboBox;
   delete _reqcObsFileChooser;
@@ -2106,4 +2127,5 @@
   settings.setValue("cmbSbas",       _cmbSbasCheckBox->checkState());
   settings.setValue("cmbIrnss",      _cmbIrnssCheckBox->checkState());
+  settings.setValue("cmbBsxFile",    _cmbBsxFile->fileName());
 
 // Upload Corrections
@@ -2118,4 +2140,5 @@
   settings.setValue("uploadSamplSp3",         _uploadSamplSp3SpinBox->value());
   settings.setValue("uploadSamplClkRnx",      _uploadSamplClkRnxSpinBox->value());
+  settings.setValue("uploadSamplBiaSnx",      _uploadSamplBiaSnxSpinBox->value());
   settings.setValue("uploadAntexFile",        _uploadAntexFile->fileName());
 // Upload Ephemeris
@@ -2629,4 +2652,5 @@
       enableWidget(true, _cmbSbasCheckBox);
       enableWidget(true, _cmbIrnssCheckBox);
+      enableWidget(true, _cmbBsxFile);
     }
     else {
@@ -2641,4 +2665,5 @@
       enableWidget(false, _cmbSbasCheckBox);
       enableWidget(false, _cmbIrnssCheckBox);
+      enableWidget(false, _cmbBsxFile);
     }
   }
@@ -2651,4 +2676,5 @@
     enableWidget(true, _uploadSamplRtcmEphCorrSpinBox);
     enableWidget(true, _uploadSamplClkRnxSpinBox);
+    enableWidget(true, _uploadSamplBiaSnxSpinBox);
     enableWidget(true, _uploadSamplSp3SpinBox);
     enableWidget(true, _uploadAntexFile);
@@ -2658,4 +2684,5 @@
     enableWidget(false, _uploadSamplRtcmEphCorrSpinBox);
     enableWidget(false, _uploadSamplClkRnxSpinBox);
+    enableWidget(false, _uploadSamplBiaSnxSpinBox);
     enableWidget(false, _uploadSamplSp3SpinBox);
     enableWidget(false, _uploadAntexFile);
@@ -2808,5 +2835,5 @@
       _uploadTable->setCellWidget(iRow, iCol, com);
     }
-    else if (iCol == 14) {
+    else if (iCol == 15) {
       bncTableItem* bncIt = new bncTableItem();
       bncIt->setFlags(bncIt->flags() & ~Qt::ItemIsEditable);
@@ -2916,5 +2943,5 @@
         _uploadTable->setCellWidget(iRow, iCol, com);
       }
-      else if (iCol == 14) {
+      else if (iCol == 15) {
         bncTableItem* bncIt = new bncTableItem();
         bncIt->setFlags(bncIt->flags() & ~Qt::ItemIsEditable);
Index: trunk/BNC/src/bncwindow.h
===================================================================
--- trunk/BNC/src/bncwindow.h	(revision 9634)
+++ trunk/BNC/src/bncwindow.h	(revision 9635)
@@ -225,4 +225,5 @@
     QCheckBox*     _cmbSbasCheckBox;
     QCheckBox*     _cmbIrnssCheckBox;
+    qtFileChooser* _cmbBsxFile;
 
     QTableWidget*  _uploadTable;
@@ -231,4 +232,5 @@
     QSpinBox*      _uploadSamplSp3SpinBox;
     QSpinBox*      _uploadSamplClkRnxSpinBox;
+    QSpinBox*      _uploadSamplBiaSnxSpinBox;
     qtFileChooser* _uploadAntexFile;
 
Index: trunk/BNC/src/combination/bnccomb.cpp
===================================================================
--- trunk/BNC/src/combination/bnccomb.cpp	(revision 9634)
+++ trunk/BNC/src/combination/bnccomb.cpp	(revision 9635)
@@ -18,4 +18,5 @@
 #include <iomanip>
 #include <sstream>
+#include <map>
 
 #include "bnccomb.h"
@@ -472,21 +473,4 @@
     }
 
-    // Check satellite code biases
-    // ----------------------------
-    if (!_satCodeBiases.contains(acName)) {
-      delete newCorr;
-      continue;
-    }
-    else {
-      QMap<t_prn, t_satCodeBias>& storage = _satCodeBiases[acName];
-      if (!storage.contains(clkCorr._prn)) {
-        delete newCorr;
-        continue;
-      }
-      else {
-        newCorr->_satCodeBias = storage[clkCorr._prn];
-      }
-    }
-
     // Check the Ephemeris
     //--------------------
@@ -520,4 +504,43 @@
         continue;
       }
+    }
+
+    // Check satellite code biases
+    // ----------------------------
+    if (!_satCodeBiases.contains(acName)) {
+      delete newCorr;
+      continue;
+    }
+    else {
+      QMap<t_prn, t_satCodeBias>& storage = _satCodeBiases[acName];
+      if (!storage.contains(clkCorr._prn)) {
+        delete newCorr;
+        continue;
+      }
+      else {
+        t_satCodeBias& satCodeBias = storage[clkCorr._prn];
+        QMap<t_frequency::type, double> codeBias;
+        for (unsigned ii = 1; ii < t_lcRefSig::cIF; ii++) {
+          t_frequency::type frqType = t_lcRefSig::toFreq(sys,  static_cast<t_lcRefSig::type>(ii));
+          char frqNum = t_frequency::toString(frqType)[1];
+          char attrib = t_lcRefSig::toAttrib(sys,  static_cast<t_lcRefSig::type>(ii));
+          QString obsType = QString("%1%2").arg(frqNum).arg(attrib);
+          for (unsigned ii = 0; ii < satCodeBias._bias.size(); ii++) {
+            const t_frqCodeBias& bias = satCodeBias._bias[ii];
+            if (obsType.toStdString() == bias._rnxType2ch) {
+              codeBias[frqType] = bias._value;
+            }
+          }
+        }
+        map<t_frequency::type, double> codeCoeff;
+        double channel = double(newCorr->_eph->slotNum());
+        t_lcRefSig::coeff(sys, t_lcRefSig::cIF, channel, codeCoeff);
+        map<t_frequency::type, double>::const_iterator it;
+        for (it = codeCoeff.begin(); it != codeCoeff.end(); it++) {
+          t_frequency::type frqType = it->first;
+          newCorr->_codeBiasIF += it->second * codeBias[frqType];
+        }
+      }
+      cout <<  acName.toStdString() << " " << clkCorr._prn.toString().c_str() << " _codeBiasIF: " << newCorr->_codeBiasIF << endl;
     }
 
@@ -597,6 +620,6 @@
   QTextStream out(&_log, QIODevice::WriteOnly);
 
-  out << endl <<           "Combination: " << sys << endl
-      << "--------------------------------" << endl;
+  out << "\n" <<           "Combination: " << sys << "\n"
+      << "--------------------------------" << "\n";
 
   // Observation Statistics
@@ -617,5 +640,5 @@
       }
     }
-    out << AC->name.toLatin1().data() << ": " << AC->numObs[sys] << endl;
+    out << AC->name.toLatin1().data() << ": " << AC->numObs[sys] << "\n";
   }
 
@@ -629,5 +652,5 @@
     ++_masterMissingEpochs[sys];
     if (_masterMissingEpochs[sys] < switchMasterAfterGap) {
-      out << "Missing Master, Epoch skipped" << endl;
+      out << "Missing Master, Epoch skipped" << "\n";
       _buffer[sys].remove(_resTime);
       emit newMessage(_log, false);
@@ -644,5 +667,5 @@
               << AC->name.toLatin1().data()   << " "
               << _resTime.datestr().c_str()    << " "
-              << _resTime.timestr().c_str()    << endl;
+              << _resTime.timestr().c_str()    << "\n";
           _masterOrbitAC[sys] = AC->name;
           break;
@@ -682,5 +705,5 @@
       out.setRealNumberPrecision(4);
       out << pp->toString(sys) << " "
-          << pp->xx << " +- " << sqrt(_QQ[sys](pp->index,pp->index)) << endl;
+          << pp->xx << " +- " << sqrt(_QQ[sys](pp->index,pp->index)) << "\n";
       out.setFieldWidth(0);
     }
@@ -762,10 +785,10 @@
       }
 
-      out << "  Outlier" << endl;
+      out << "  Outlier" << "\n";
       _QQ[sys] = QQ_sav;
       corrs(sys).remove(maxResIndex-1);
     }
     else {
-      out << "  OK" << endl;
+      out << "  OK" << "\n";
       out.setRealNumberNotation(QTextStream::FixedNotation);
       out.setRealNumberPrecision(4);
@@ -776,5 +799,5 @@
             << corr->_acName << ' ' << corr->_prn.mid(0,3);
         out.setFieldWidth(10);
-        out <<  " res = " << vv[ii] << endl;
+        out <<  " res = " << vv[ii] << "\n";
         out.setFieldWidth(0);
       }
@@ -807,9 +830,9 @@
       out << "Full Clock " << corr->_prn.mid(0,3) << " " << corr->_iod << " ";
       out.setFieldWidth(14);
-      out << (xc(4) + corr->_dClkResult) * t_CST::c << endl;
+      out << (xc(4) + corr->_dClkResult) * t_CST::c << "\n";
       out.setFieldWidth(0);
     }
     else {
-      out << "bncComb::printResuls bug" << endl;
+      out << "bncComb::printResuls bug" << "\n";
     }
   }
@@ -958,5 +981,5 @@
     }
 
-    ll(iObs) = corr->_clkCorr._dClk * t_CST::c - DotProduct(AA.Row(iObs), x0);
+    ll(iObs) = (corr->_clkCorr._dClk * t_CST::c - corr->_codeBiasIF) - DotProduct(AA.Row(iObs), x0);
   }
 
@@ -1117,5 +1140,5 @@
     }
     catch (Exception& exc) {
-      out << exc.what() << endl;
+      out << exc.what() << "\n";
       return failure;
     }
@@ -1130,10 +1153,10 @@
 
     if (maxRes > _MAXRES) {
-      out << "  Outlier" << endl;
+      out << "  Outlier" << "\n";
       delete corrs(sys)[maxResIndex-1];
       corrs(sys).remove(maxResIndex-1);
     }
     else {
-      out << "  OK" << endl;
+      out << "  OK" << "\n";
       out.setRealNumberNotation(QTextStream::FixedNotation);
       out.setRealNumberPrecision(3);
@@ -1144,5 +1167,5 @@
             << corr->_acName << ' ' << corr->_prn.mid(0,3);
         out.setFieldWidth(6);
-        out << " res = " << vv[ii] << endl;
+        out << " res = " << vv[ii] << "\n";
         out.setFieldWidth(0);
       }
@@ -1172,10 +1195,10 @@
 
     if      (ephLast == 0) {
-      out << "checkOrbit: missing eph (not found) " << corr->_prn.mid(0,3) << endl;
+      out << "checkOrbit: missing eph (not found) " << corr->_prn.mid(0,3) << "\n";
       delete corr;
       im.remove();
     }
     else if (corr->_eph == 0) {
-      out << "checkOrbit: missing eph (zero) " << corr->_prn.mid(0,3) << endl;
+      out << "checkOrbit: missing eph (zero) " << corr->_prn.mid(0,3) << "\n";
       delete corr;
       im.remove();
@@ -1186,5 +1209,5 @@
       }
       else {
-        out << "checkOrbit: missing eph (deleted) " << corr->_prn.mid(0,3) << endl;
+        out << "checkOrbit: missing eph (deleted) " << corr->_prn.mid(0,3) << "\n";
         delete corr;
         im.remove();
@@ -1268,5 +1291,5 @@
               << prn.mid(0,3).toLatin1().data()           << " "
               << corr->_iod                     << " "
-              << norm                           << endl;
+              << norm                           << "\n";
           delete corr;
           im.remove();
@@ -1301,5 +1324,5 @@
       out << "Provider ID changed: AC " << AC->name.toLatin1().data()   << " "
           << _resTime.datestr().c_str()    << " "
-          << _resTime.timestr().c_str()    << endl;
+          << _resTime.timestr().c_str()    << "\n";
       break;
     }
Index: trunk/BNC/src/combination/bnccomb.h
===================================================================
--- trunk/BNC/src/combination/bnccomb.h	(revision 9634)
+++ trunk/BNC/src/combination/bnccomb.h	(revision 9635)
@@ -4,7 +4,9 @@
 
 #include <fstream>
+#include <map>
 #include <newmat.h>
 #include "bncephuser.h"
 #include "satObs.h"
+#include "bncconst.h"
 #include "../RTCM3/clock_and_orbit/clock_orbit_rtcm.h"
 #include "../RTCM3/clock_and_orbit/clock_orbit_igs.h"
@@ -80,4 +82,5 @@
       _iod        = 0;
       _dClkResult = 0.0;
+      _codeBiasIF   = 0.0;
     }
     ~cmbCorr() {}
@@ -90,4 +93,5 @@
     t_satCodeBias _satCodeBias;
     QString       _acName;
+    double        _codeBiasIF;
     double        _dClkResult;
     ColumnVector  _diffRao;
@@ -106,4 +110,84 @@
     QVector<cmbCorr*> corrs;
   };
+
+  class t_lcRefSig {
+   public:
+    enum type {dummy = 0, c1, c2, cIF};
+
+    static t_frequency::type toFreq(char sys, type tt) {
+      switch (tt) {
+      case c1:
+        if      (sys == 'G') return t_frequency::G1;
+        else if (sys == 'R') return t_frequency::R1;
+        else if (sys == 'E') return t_frequency::E1;
+        else if (sys == 'C') return t_frequency::C2;
+        else if (sys == 'J') return t_frequency::J1;
+        else if (sys == 'S') return t_frequency::S1;
+        else                 return t_frequency::dummy;
+      case c2:
+        if      (sys == 'G') return t_frequency::G2;
+        else if (sys == 'R') return t_frequency::R2;
+        else if (sys == 'E') return t_frequency::E5;
+        else if (sys == 'C') return t_frequency::C6;
+        else if (sys == 'J') return t_frequency::J2;
+        else if (sys == 'S') return t_frequency::S5;
+        else                 return t_frequency::dummy;
+      case dummy:
+      case cIF:
+        return t_frequency::dummy;
+      }
+      return t_frequency::dummy;
+    }
+
+    static char toAttrib(char sys, type LC) {
+      switch (LC) {
+        case c1:
+          if      (sys == 'G') return 'W';
+          else if (sys == 'R') return 'P';
+          else if (sys == 'E') return 'C';
+          else if (sys == 'C') return 'I';
+          else if (sys == 'J') return 'C';
+          else if (sys == 'S') return 'C';
+          break;
+        case c2:
+          if      (sys == 'G') return 'W';
+          else if (sys == 'R') return 'P';
+          else if (sys == 'E') return 'Q';
+          else if (sys == 'C') return 'I';
+          else if (sys == 'J') return 'L';
+          else if (sys == 'S') return 'Q';
+          break;
+      case dummy:
+      case cIF:
+        return '_';
+        break;
+      }
+      return '_';
+    }
+
+      static void coeff(char sys, type tLC, double channel, std::map<t_frequency::type, double>& codeCoeff)  {
+      codeCoeff.clear();
+      t_frequency::type fType1 = toFreq(sys, c1);
+      t_frequency::type fType2 = toFreq(sys, c2);
+      double f1 = t_CST::freq(fType1, channel);
+      double f2 = t_CST::freq(fType2, channel);
+      switch (tLC) {
+        case c1:
+          codeCoeff[fType1] = 1.0;
+          return;
+        case c2:
+          codeCoeff[fType2] = 1.0;
+          return;
+        case cIF:
+          codeCoeff[fType1] =  f1 * f1 / (f1 * f1 - f2 * f2);
+          codeCoeff[fType2] = -f2 * f2 / (f1 * f1 - f2 * f2);
+          return;
+        case t_lcRefSig::dummy:
+          return;
+      }
+      return;
+    }
+  };
+
 
   void  processEpoch(char sys);
@@ -134,4 +218,5 @@
   e_method                                   _method;
   int                                        _cmbSampl;
+  QString                                    _cmbRefAttributes;
   QMap<QString, QMap<t_prn, t_orbCorr> >     _orbCorrections;
   QMap<QString, QMap<t_prn, t_satCodeBias> > _satCodeBiases;
