Index: branches/BNC_2.12/src/upload/bncephuploadcaster.cpp
===================================================================
--- branches/BNC_2.12/src/upload/bncephuploadcaster.cpp	(revision 9393)
+++ branches/BNC_2.12/src/upload/bncephuploadcaster.cpp	(revision 9407)
@@ -59,58 +59,62 @@
 ////////////////////////////////////////////////////////////////////////////
 void bncEphUploadCaster::ephBufferChanged() {
-  if (_ephUploadCaster) {
-    QByteArray outBuffer;
+	if (_ephUploadCaster) {
+		QByteArray outBuffer;
 
-    QDateTime now = currentDateAndTimeGPS();
-    bncTime currentTime(now.toString(Qt::ISODate).toStdString());
+		QDateTime now = currentDateAndTimeGPS();
+		bncTime currentTime(now.toString(Qt::ISODate).toStdString());
 
-    QListIterator<QString> it(prnList());
-    while (it.hasNext()) {
-      const t_eph* eph = ephLast(it.next());
+		QListIterator < QString > it(prnList());
+		while (it.hasNext()) {
+			const t_eph *eph = ephLast(it.next());
 
-      bncTime toc = eph->TOC();
-      double timeDiff = fabs(toc - currentTime);
+			bncTime toc = eph->TOC();
+			double dt = currentTime - toc;
 
-      const t_ephGPS*  ephGPS  = dynamic_cast<const t_ephGPS*>(eph);
-      const t_ephGlo*  ephGlo  = dynamic_cast<const t_ephGlo*>(eph);
-      const t_ephGal*  ephGal  = dynamic_cast<const t_ephGal*>(eph);
-      const t_ephSBAS* ephSBAS = dynamic_cast<const t_ephSBAS*>(eph);
-      const t_ephBDS*  ephBDS  = dynamic_cast<const t_ephBDS*>(eph);
+			const t_ephGPS *ephGPS = dynamic_cast<const t_ephGPS*>(eph);
+			const t_ephGlo *ephGlo = dynamic_cast<const t_ephGlo*>(eph);
+			const t_ephGal *ephGal = dynamic_cast<const t_ephGal*>(eph);
+			const t_ephSBAS *ephSBAS = dynamic_cast<const t_ephSBAS*>(eph);
+			const t_ephBDS *ephBDS = dynamic_cast<const t_ephBDS*>(eph);
 
-      unsigned char Array[80];
-      int size = 0;
+			unsigned char Array[80];
+			int size = 0;
 
-      if (ephGPS) {
-        if (timeDiff <= 4*3600) {
-          size = t_ephEncoder::RTCM3(*ephGPS, Array);
-        }
-      }
-      else if (ephGlo) {
-        if (timeDiff <= 1*3600) {
-          size = t_ephEncoder::RTCM3(*ephGlo, Array);
-        }
-      }
-      else if (ephGal) {
-        if (timeDiff <= 4*3600) {
-          size = t_ephEncoder::RTCM3(*ephGal, Array);
-        }
-      }
-      else if (ephSBAS) {
-        if (timeDiff <= 600) {
-          size = t_ephEncoder::RTCM3(*ephSBAS, Array);
-        }
-      }
-      else if (ephBDS) {
-        if (timeDiff <= 6*3600) {
-          size = t_ephEncoder::RTCM3(*ephBDS, Array);
-        }
-      }
-      if (size > 0) {
-        outBuffer += QByteArray((char*) Array, size);
-      }
-    }
-    if (outBuffer.size() > 0) {
-      _ephUploadCaster->setOutBuffer(outBuffer);
-    }
-  }
+			if (ephGPS && ephGPS->type() == t_eph::GPS && (system == "ALL" || system == "GPS")) {
+				if (dt > 14400.0 || dt < -7200.0) {
+					size = t_ephEncoder::RTCM3(*ephGPS, Array);
+				}
+			} else if (ephGPS && ephGPS->type() == t_eph::QZSS && (system == "ALL" || system == "QZSS")) {
+				if (dt > 7200.0 || dt < -3600.0) {
+					size = t_ephEncoder::RTCM3(*ephGPS, Array);
+				}
+			} else if (ephGlo && (system == "ALL" || system == "GLONASS")) {
+				if (dt > 3900.0 || dt < -2100.0) {
+					size = t_ephEncoder::RTCM3(*ephGlo, Array);
+				}
+			} else if (ephGal && (system == "ALL" || system == "Galileo")) {
+				if (dt > 14400.0 || dt < 0.0) {
+					size = t_ephEncoder::RTCM3(*ephGal, Array);
+				}
+			} else if (ephSBAS && (system == "ALL" || system == "SBAS")) {
+				if (dt > 600.0 || dt < -600.0) {
+					size = t_ephEncoder::RTCM3(*ephSBAS, Array);
+				}
+			} else if (ephBDS && (system == "ALL" || system == "BDS")) {
+				if (dt > 3900.0 || dt < 0.0) {
+					size = t_ephEncoder::RTCM3(*ephBDS, Array);
+				}
+			} else if (ephGPS && ephGPS->type() == t_eph::IRNSS	&& (system == "ALL" || system == "IRNSS")) {
+				if (fabs(dt > 86400.0)) {
+					size = t_ephEncoder::RTCM3(*ephGPS, Array);
+				}
+			}
+			if (size > 0) {
+				outBuffer += QByteArray((char*) Array, size);
+			}
+		}
+		if (outBuffer.size() > 0) {
+			_ephUploadCaster->setOutBuffer(outBuffer);
+		}
+	}
 }
