Index: trunk/BNC/RTCM3/RTCM3Decoder.cpp
===================================================================
--- trunk/BNC/RTCM3/RTCM3Decoder.cpp	(revision 3000)
+++ trunk/BNC/RTCM3/RTCM3Decoder.cpp	(revision 3001)
@@ -81,8 +81,4 @@
           (bncApp*) qApp, SLOT(slotNewGalileoEph(galileoephemeris*)));
 
-  // Sub-Decoder for Clock and Orbit Corrections
-  // -------------------------------------------
-  _coDecoder = new RTCM3coDecoder(staID);
-
   // Mode can be either observations or corrections
   // ----------------------------------------------
@@ -98,5 +94,8 @@
 ////////////////////////////////////////////////////////////////////////////
 RTCM3Decoder::~RTCM3Decoder() {
-  delete _coDecoder;
+  QMapIterator<QByteArray, RTCM3coDecoder*> it(_coDecoders);
+  while (it.hasNext()) {
+    delete it.next();
+  }
 }
 
@@ -109,50 +108,34 @@
   bool decoded = false;
 
-  // If read from file, we set the mode according to staID
-  // -----------------------------------------------------
-  if (!_staID_corrections.isEmpty() && _rawFile) {
-    if (_rawFile->staID() == _staID_corrections) {
-      _mode = corrections;
-    }
-    else {
-      _mode = observations;
-    }
-  }
+  // If read from file, mode is always uknown
+  // ----------------------------------------
+  if (_rawFile) {
+    _mode  = unknown;
+    _staID = _rawFile->staID();
+  }
+
+  // Find the corresponding coDecoder, initialize a new one if necessary
+  // -------------------------------------------------------------------
+  if (!_coDecoders.contains(_staID.toAscii())) {
+    _coDecoders[_staID.toAscii()] = new RTCM3coDecoder(_staID); 
+  }
+  RTCM3coDecoder* coDecoder = _coDecoders[_staID.toAscii()];
 
   // Try to decode Clock and Orbit Corrections
   // -----------------------------------------
   if (_mode == unknown || _mode == corrections) {
-    if ( _coDecoder->Decode(buffer, bufLen, errmsg) == success ) {
+    if ( coDecoder->Decode(buffer, bufLen, errmsg) == success ) {
       decoded = true;
-      if (_mode == unknown) {
-        if (_rawFile) {
-          _staID_corrections = _rawFile->staID();
-        }
-        else {
-          _mode = corrections;
-        }
+      if  (!_rawFile && _mode == unknown) {
+        _mode = corrections;
       }
     }
   }
 
-  // Find the corresponding parser
-  // -----------------------------
-  QByteArray staID("default");
-  if (_rawFile) {
-    staID = _rawFile->staID();
-  }
-
-  bool newParser = !_parsers.contains(staID);
-
-  RTCM3ParserData& parser = _parsers[staID];
-
-  // Get Glonass Slot Numbers from Global Array
-  // ------------------------------------------
-  bncApp* app = (bncApp*) qApp;
-  app->getGlonassSlotNums(parser.GLOFreq);
-
-  // Initialize a new parser
-  // -----------------------
-  if (newParser) {
+  // Find the corresponding parser, initialize a new parser if necessary
+  // -------------------------------------------------------------------
+  bool newParser = !_parsers.contains(_staID.toAscii());
+  RTCM3ParserData& parser = _parsers[_staID.toAscii()];
+  if (newParser) {  
     memset(&parser, 0, sizeof(parser));
     parser.rinex3 = 0;
@@ -161,4 +144,9 @@
     parser.GPSTOW = int(secGPS);
   }
+
+  // Get Glonass Slot Numbers from Global Array
+  // ------------------------------------------
+  bncApp* app = (bncApp*) qApp;
+  app->getGlonassSlotNums(parser.GLOFreq);
 
   // Remaining part decodes the Observations
@@ -338,13 +326,4 @@
                 unsigned df = (1 << iEntry);
 
-                //// beg test
-                ////  cout << prn.toAscii().data() << " "
-                ////       << iEntry << " " << df;
-                ////  if (df & gnssData.dataflags[iSat]) {
-                ////    cout << " present";
-                ////  }
-                ////  cout << endl;
-                //// end test
-
                 if (df & gnssData.dataflags[iSat]) {
 
@@ -478,2 +457,13 @@
   return false;
 }
+
+// Time of Corrections
+//////////////////////////////////////////////////////////////////////////////
+int RTCM3Decoder::corrGPSEpochTime() const {
+  if (_mode == corrections && _coDecoders.size() > 0) {
+    return _coDecoders.begin().value()->corrGPSEpochTime();
+  }
+  else {
+    return -1;
+  }
+}
Index: trunk/BNC/RTCM3/RTCM3Decoder.h
===================================================================
--- trunk/BNC/RTCM3/RTCM3Decoder.h	(revision 3000)
+++ trunk/BNC/RTCM3/RTCM3Decoder.h	(revision 3001)
@@ -45,7 +45,5 @@
   virtual ~RTCM3Decoder();
   virtual t_irc Decode(char* buffer, int bufLen, std::vector<std::string>& errmsg);
-  virtual int corrGPSEpochTime() const {
-    return (_mode == corrections ? _coDecoder->corrGPSEpochTime() : -1);
-  }
+  virtual int corrGPSEpochTime() const;
 
   bool  storeEph(const gpsephemeris& gpseph);
@@ -64,5 +62,5 @@
   QString                _checkMountPoint;
   QMap<QByteArray, RTCM3ParserData> _parsers;
-  RTCM3coDecoder*        _coDecoder; 
+  QMap<QByteArray, RTCM3coDecoder*> _coDecoders; 
   t_mode                 _mode;
 
@@ -70,5 +68,4 @@
   double                 _antXYZ[3];
   bncRawFile*            _rawFile;
-  QString                _staID_corrections;
 
   QMap<QString, int>  _slip_cnt_L1;
