Index: branches/BNC_2.12/src/RTCM3/RTCM3coDecoder.cpp
===================================================================
--- branches/BNC_2.12/src/RTCM3/RTCM3coDecoder.cpp	(revision 8987)
+++ branches/BNC_2.12/src/RTCM3/RTCM3coDecoder.cpp	(revision 9036)
@@ -53,5 +53,5 @@
 // Constructor
 ////////////////////////////////////////////////////////////////////////////
-RTCM3coDecoder::RTCM3coDecoder(const QString& staID) {
+RTCM3coDecoder::RTCM3coDecoder(const QString& staID, const e_type type) {
 
   _staID = staID;
@@ -96,4 +96,7 @@
   _providerID[1] = -1;
   _providerID[2] = -1;
+
+  _type = type;
+  _ssrCorr = 0;
 }
 
@@ -102,4 +105,5 @@
 RTCM3coDecoder::~RTCM3coDecoder() {
   delete _out;
+  delete _ssrCorr;
   _IODs.clear();
   _orbCorrections.clear();
@@ -166,8 +170,8 @@
   while(_buffer.size()) {
 
-    struct ClockOrbit clkOrbSav;
-    struct CodeBias   codeBiasSav;
-    struct PhaseBias  phaseBiasSav;
-    struct VTEC       vTECSav;
+    struct SsrCorr::ClockOrbit clkOrbSav;
+    struct SsrCorr::CodeBias   codeBiasSav;
+    struct SsrCorr::PhaseBias  phaseBiasSav;
+    struct SsrCorr::VTEC       vTECSav;
     memcpy(&clkOrbSav,    &_clkOrb,    sizeof(clkOrbSav)); // save state
     memcpy(&codeBiasSav,  &_codeBias,  sizeof(codeBiasSav));
@@ -176,5 +180,11 @@
 
     int bytesused = 0;
-    GCOB_RETURN irc = GetSSR(&_clkOrb, &_codeBias, &_vTEC, &_phaseBias,
+    if (_type == e_type::RTCMssr) {
+      _ssrCorr = new SsrCorrRtcm();
+    }
+    else {
+      _ssrCorr = new SsrCorrIgs();
+    }
+    GCOB_RETURN irc = _ssrCorr->GetSSR(&_clkOrb, &_codeBias, &_vTEC, &_phaseBias,
                              _buffer.data(), _buffer.size(), &bytesused);
 
@@ -259,18 +269,19 @@
       continue;
     }
+
     // Orbit correction
     // ----------------
-    if ( _clkOrb.messageType == COTYPE_GPSCOMBINED     ||
-         _clkOrb.messageType == COTYPE_GLONASSCOMBINED ||
-         _clkOrb.messageType == COTYPE_GALILEOCOMBINED ||
-         _clkOrb.messageType == COTYPE_QZSSCOMBINED ||
-         _clkOrb.messageType == COTYPE_SBASCOMBINED ||
-         _clkOrb.messageType == COTYPE_BDSCOMBINED ||
-         _clkOrb.messageType == COTYPE_GPSORBIT ||
-         _clkOrb.messageType == COTYPE_GLONASSORBIT ||
-         _clkOrb.messageType == COTYPE_GALILEOORBIT ||
-         _clkOrb.messageType == COTYPE_QZSSORBIT ||
-         _clkOrb.messageType == COTYPE_SBASORBIT ||
-         _clkOrb.messageType == COTYPE_BDSORBIT ) {
+    if ( _clkOrb.messageType == _ssrCorr->COTYPE_GPSCOMBINED     ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_GLONASSCOMBINED ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_GALILEOCOMBINED ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_QZSSCOMBINED ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_SBASCOMBINED ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_BDSCOMBINED ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_GPSORBIT ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_GLONASSORBIT ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_GALILEOORBIT ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_QZSSORBIT ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_SBASORBIT ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_BDSORBIT ) {
 
       t_orbCorr orbCorr;
@@ -295,16 +306,16 @@
     // Clock Corrections
     // -----------------
-    if ( _clkOrb.messageType == COTYPE_GPSCOMBINED     ||
-         _clkOrb.messageType == COTYPE_GLONASSCOMBINED ||
-         _clkOrb.messageType == COTYPE_GALILEOCOMBINED ||
-         _clkOrb.messageType == COTYPE_QZSSCOMBINED ||
-         _clkOrb.messageType == COTYPE_SBASCOMBINED ||
-         _clkOrb.messageType == COTYPE_BDSCOMBINED ||
-         _clkOrb.messageType == COTYPE_GPSCLOCK ||
-         _clkOrb.messageType == COTYPE_GLONASSCLOCK ||
-         _clkOrb.messageType == COTYPE_GALILEOCLOCK ||
-         _clkOrb.messageType == COTYPE_QZSSCLOCK ||
-         _clkOrb.messageType == COTYPE_SBASCLOCK ||
-         _clkOrb.messageType == COTYPE_BDSCLOCK) {
+    if ( _clkOrb.messageType == _ssrCorr->COTYPE_GPSCOMBINED     ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_GLONASSCOMBINED ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_GALILEOCOMBINED ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_QZSSCOMBINED ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_SBASCOMBINED ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_BDSCOMBINED ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_GPSCLOCK ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_GLONASSCLOCK ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_GALILEOCLOCK ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_QZSSCLOCK ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_SBASCLOCK ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_BDSCLOCK) {
 
       t_clkCorr clkCorr;
@@ -327,10 +338,10 @@
     // High-Resolution Clocks
     // ----------------------
-    if ( _clkOrb.messageType == COTYPE_GPSHR     ||
-         _clkOrb.messageType == COTYPE_GLONASSHR ||
-         _clkOrb.messageType == COTYPE_GALILEOHR ||
-         _clkOrb.messageType == COTYPE_QZSSHR ||
-         _clkOrb.messageType == COTYPE_SBASHR ||
-         _clkOrb.messageType == COTYPE_BDSHR) {
+    if ( _clkOrb.messageType == _ssrCorr->COTYPE_GPSHR     ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_GLONASSHR ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_GALILEOHR ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_QZSSHR ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_SBASHR ||
+         _clkOrb.messageType == _ssrCorr->COTYPE_BDSHR) {
       t_prn prn(sysCh, _clkOrb.Sat[ii].ID, flag);
       if (_lastClkCorrections.contains(prn)) {
@@ -390,7 +401,7 @@
     satCodeBias._updateInt = _codeBias.UpdateInterval;
     for (unsigned jj = 0; jj < _codeBias.Sat[ii].NumberOfCodeBiases; jj++) {
-      const CodeBias::BiasSat::CodeBiasEntry& biasEntry = _codeBias.Sat[ii].Biases[jj];
+      const SsrCorr::CodeBias::BiasSat::CodeBiasEntry& biasEntry = _codeBias.Sat[ii].Biases[jj];
       t_frqCodeBias frqCodeBias;
-      frqCodeBias._rnxType2ch.assign(codeTypeToRnxType(sysCh, biasEntry.Type));
+      frqCodeBias._rnxType2ch.assign(_ssrCorr->codeTypeToRnxType(sysCh, biasEntry.Type));
       frqCodeBias._value      = biasEntry.Bias;
       if (!frqCodeBias._rnxType2ch.empty()) {
@@ -447,7 +458,7 @@
     satPhaseBias._yawDegRate = _phaseBias.Sat[ii].YawRate * 180.0 / M_PI;
     for (unsigned jj = 0; jj < _phaseBias.Sat[ii].NumberOfPhaseBiases; jj++) {
-      const PhaseBias::PhaseBiasSat::PhaseBiasEntry& biasEntry = _phaseBias.Sat[ii].Biases[jj];
+      const SsrCorr::PhaseBias::PhaseBiasSat::PhaseBiasEntry& biasEntry = _phaseBias.Sat[ii].Biases[jj];
       t_frqPhaseBias frqPhaseBias;
-      frqPhaseBias._rnxType2ch.assign(codeTypeToRnxType(sysCh, biasEntry.Type));
+      frqPhaseBias._rnxType2ch.assign(_ssrCorr->codeTypeToRnxType(sysCh, biasEntry.Type));
       frqPhaseBias._value                = biasEntry.Bias;
       frqPhaseBias._fixIndicator         = biasEntry.SignalIntegerIndicator;
@@ -468,5 +479,5 @@
     _vTecMap[_lastTime]._staID = _staID.toStdString();
     for (unsigned ii = 0; ii < _vTEC.NumLayers; ii++) {
-      const VTEC::IonoLayers& ionoLayer = _vTEC.Layers[ii];
+      const SsrCorr::VTEC::IonoLayers& ionoLayer = _vTEC.Layers[ii];
       t_vTecLayer layer;
       layer._height = ionoLayer.Height;
@@ -647,8 +658,8 @@
   }
   else if (epoSecGlo != -1) {
-#ifdef USE_SSR_RTCM
-    QDate date = dateAndTimeFromGPSweek(currentTime.gpsw(), currentTime.gpssec()).date();
-    epoSecGlo = epoSecGlo - 3 * 3600 + gnumleap(date.year(), date.month(), date.day());
-#endif
+    if (_type == e_type::RTCMssr) {
+      QDate date = dateAndTimeFromGPSweek(currentTime.gpsw(), currentTime.gpssec()).date();
+      epoSecGlo = epoSecGlo - 3 * 3600 + gnumleap(date.year(), date.month(), date.day());
+    }
     _lastTime.set(currentWeek, epoSecGlo);
   }
@@ -663,10 +674,10 @@
   }
   else if (epoSecBds != -1) {
-#ifdef USE_SSR_RTCM
-    epoSecBds += 14.0;
-    if (epoSecBds > 604800.0) {
-      epoSecBds -= 7.0*24.0*60.0*60.0;
-    }
-#endif
+    if (_type == e_type::RTCMssr) {
+      epoSecBds += 14.0;
+      if (epoSecBds > 604800.0) {
+        epoSecBds -= 7.0*24.0*60.0*60.0;
+      }
+    }
     _lastTime.set(currentWeek, epoSecBds);
   }
@@ -682,176 +693,2 @@
   }
 }
-
-//
-////////////////////////////////////////////////////////////////////////////
-string RTCM3coDecoder::codeTypeToRnxType(char system, CodeType type) const {
-  if      (system == 'G') {
-    switch (type) {
-      case CODETYPEGPS_L1_CA:         return "1C";
-      case CODETYPEGPS_L1_P:          return "1P";
-      case CODETYPEGPS_L1_Z:          return "1W";
-
-      case CODETYPEGPS_SEMI_CODELESS: return "2D";
-      case CODETYPEGPS_L2_CA:         return "2C";
-      case CODETYPEGPS_L2_P:          return "2P";
-      case CODETYPEGPS_L2_Z:          return "2W";
-
-      case CODETYPEGPS_L2C_M:         return "2S";
-      case CODETYPEGPS_L2C_L:         return "2L";
-#ifdef USE_SSR_RTCM
-      case CODETYPEGPS_L2C_ML:        return "2X";
-#endif
-
-      case CODETYPEGPS_L5_I:          return "5I";
-      case CODETYPEGPS_L5_Q:          return "5Q";
-#ifdef USE_SSR_RTCM
-      case CODETYPEGPS_L5_IQ:         return "5X";
-#endif
-      case CODETYPEGPS_L1C_D:         return "1S";
-      case CODETYPEGPS_L1C_P:         return "1L";
-#ifdef USE_SSR_RTCM
-      case CODETYPEGPS_L1C_DP:        return "1X";
-#endif
-      default: return "";
-    }
-  }
-  else if (system == 'R') {
-    switch (type) {
-      case CODETYPEGLONASS_L1_CA:     return "1C";
-      case CODETYPEGLONASS_L1_P:      return "1P";
-      case CODETYPEGLONASS_L2_CA:     return "2C";
-      case CODETYPEGLONASS_L2_P:      return "2P";
-      case CODETYPEGLONASS_L1a_OCd:   return "4A";
-      case CODETYPEGLONASS_L1a_OCp:   return "4B";
-#ifdef USE_SSR_RTCM
-      case CODETYPEGLONASS_L1a_OCdp:  return "4X";
-#endif
-      case CODETYPEGLONASS_L2a_CSI:   return "6A";
-      case CODETYPEGLONASS_L2a_OCp:   return "6B";
-#ifdef USE_SSR_RTCM
-      case CODETYPEGLONASS_L2a_CSIOCp:return "6X";
-#endif
-      case CODETYPEGLONASS_L3_I:      return "3I";
-      case CODETYPEGLONASS_L3_Q:      return "3Q";
-#ifdef USE_SSR_RTCM
-      case CODETYPEGLONASS_L3_IQ:     return "3X";
-#endif
-      default: return "";
-    }
-  }
-  else if (system == 'E') {
-    switch (type) {
-      case CODETYPEGALILEO_E1_A:       return "1A";
-      case CODETYPEGALILEO_E1_B:       return "1B";
-      case CODETYPEGALILEO_E1_C:       return "1C";
-#ifdef USE_SSR_RTCM
-      case CODETYPEGALILEO_E1_BC:      return "1X";
-      case CODETYPEGALILEO_E1_ABC:     return "1Z";
-#endif
-      case CODETYPEGALILEO_E5A_I:      return "5I";
-      case CODETYPEGALILEO_E5A_Q:      return "5Q";
-#ifdef USE_SSR_RTCM
-      case CODETYPEGALILEO_E5A_IQ:     return "5X";
-#endif
-      case CODETYPEGALILEO_E5B_I:      return "7I";
-      case CODETYPEGALILEO_E5B_Q:      return "7Q";
-#ifdef USE_SSR_RTCM
-      case CODETYPEGALILEO_E5B_IQ:     return "7X";
-
-      case CODETYPEGALILEO_E5_I:       return "8I";
-      case CODETYPEGALILEO_E5_Q:       return "8Q";
-      case CODETYPEGALILEO_E5_IQ:      return "8X";
-#endif
-      case CODETYPEGALILEO_E6_A:       return "6A";
-      case CODETYPEGALILEO_E6_B:       return "6B";
-      case CODETYPEGALILEO_E6_C:       return "6C";
-#ifdef USE_SSR_RTCM
-      case CODETYPEGALILEO_E6_BC:      return "6X";
-      case CODETYPEGALILEO_E6_ABC:     return "6Z";
-#endif
-      default: return "";
-    }
-  }
-   else if (system == 'J') {
-    switch (type) {
-      case CODETYPEQZSS_L1_CA:         return "1C";
-      case CODETYPEQZSS_L1C_D:         return "1S";
-      case CODETYPEQZSS_L1C_P:         return "1L";
-
-      case CODETYPEQZSS_L2C_M:         return "2S";
-      case CODETYPEQZSS_L2C_L:         return "2L";
-#ifdef USE_SSR_RTCM
-      case CODETYPEQZSS_L2C_ML:        return "2X";
-#endif
-      case CODETYPEQZSS_L5_I:          return "5I";
-      case CODETYPEQZSS_L5_Q:          return "5Q";
-#ifdef USE_SSR_RTCM
-      case CODETYPEQZSS_L5_IQ:         return "5X";
-#endif
-      case CODETYPEQZSS_L6_D:          return "6S";
-      case CODETYPEQZSS_L6_P:          return "6L";
-#ifdef USE_SSR_RTCM
-      case CODETYPEQZSS_L6_DP:         return "6X";
-
-      case CODETYPEQZSS_L1C_DP:        return "1X";
-      case CODETYPEQZSS_L1_S:          return "1Z";
-
-      case CODETYPEQZSS_L5_D:          return "5D";
-      case CODETYPEQZSS_L5_P:          return "5P";
-      case CODETYPEQZSS_L5_DP:         return "5Z";
-#endif
-
-      case CODETYPEQZSS_L6_E:          return "6E";
-#ifdef USE_SSR_RTCM
-      case CODETYPEQZSS_L6_DE:         return "6Z";
-#endif
-      default: return "";
-    }
-  }
-  else if (system == 'C') {
-    switch (type) {
-      case CODETYPE_BDS_B1_I:         return "2I";
-      case CODETYPE_BDS_B1_Q:         return "2Q";
-#ifdef USE_SSR_RTCM
-      case CODETYPE_BDS_B1_IQ:        return "2X";
-#endif
-      case CODETYPE_BDS_B3_I:         return "6I";
-      case CODETYPE_BDS_B3_Q:         return "6Q";
-#ifdef USE_SSR_RTCM
-      case CODETYPE_BDS_B3_IQ:        return "6X";
-#endif
-      case CODETYPE_BDS_B2_I:         return "7I";
-      case CODETYPE_BDS_B2_Q:         return "7Q";
-#ifdef USE_SSR_RTCM
-      case CODETYPE_BDS_B2_IQ:        return "7X";
-#endif
-      case CODETYPE_BDS_B1a_D:        return "1D";
-      case CODETYPE_BDS_B1a_P:        return "1P";
-#ifdef USE_SSR_RTCM
-      case CODETYPE_BDS_B1a_DP:       return "1X";
-#endif
-      case CODETYPE_BDS_B2a_D:        return "5D";
-      case CODETYPE_BDS_B2a_P:        return "5P";
-#ifdef USE_SSR_RTCM
-      case CODETYPE_BDS_B2a_DP:       return "5X";
-#elif USE_SSR_IGS
-      case CODETYPE_BDS_B1_A:         return "1A";
-      case CODETYPE_BDS_B3_A:         return "6A";
-#endif
-      default: return "";
-    }
-  }
-  else if (system == 'S') {
-    switch (type) {
-      case CODETYPE_SBAS_L1_CA:       return "1C";
-
-      case CODETYPE_SBAS_L5_I:        return "5I";
-      case CODETYPE_SBAS_L5_Q:        return "5Q";
-#ifdef USE_SSR_RTCM
-      case CODETYPE_SBAS_L5_IQ:       return "5X";
-#endif
-      default: return "";
-    }
-  }
-  return "";
-};
