Index: trunk/BNC/src/RTCM3/RTCM3Decoder.h
===================================================================
--- trunk/BNC/src/RTCM3/RTCM3Decoder.h	(revision 6598)
+++ trunk/BNC/src/RTCM3/RTCM3Decoder.h	(revision 6812)
@@ -29,12 +29,9 @@
 #include <map>
 
+#include <stdint.h>
 #include "GPSDecoder.h"
 #include "RTCM3coDecoder.h"
 #include "bncrawfile.h"
 #include "ephemeris.h"
-
-extern "C" {
-#include "rtcm3torinex.h"
-}
 
 class RTCM3Decoder : public QObject, public GPSDecoder {
@@ -45,4 +42,11 @@
   virtual t_irc Decode(char* buffer, int bufLen, std::vector<std::string>& errmsg);
   virtual int corrGPSEpochTime() const;
+  /**
+   * CRC24Q checksum calculation function (only full bytes supported).
+   * @param size Size of the passed data
+   * @param buf Data buffer containing the data to checksum
+   * @return the CRC24Q checksum of the data
+   */
+  static uint32_t CRC24(long size, const unsigned char *buf);
 
  signals:
@@ -55,18 +59,134 @@
 
  private:
-  enum t_mode{unknown = 0, observations, corrections};
+  /**
+   * Extract a RTCM3 message. Data is passed in the follow fields:<br>
+   * {@link _Message}: contains the message bytes<br>
+   * {@link _MessageSize}: contains to current amount of bytes in the buffer<br>
+   * {@link _SkipBytes}: amount of bytes to skip at the beginning of the buffer
+   * 
+   * The functions sets following variables:<br>
+   * {@link _NeedBytes}: Minimum number of bytes needed on next call<br>
+   * {@link _SkipBytes}: internal, Bytes to skip before next call (usually the amount of
+   *   found bytes)<br>
+   * {@link _MessageSize}: Updated size after processed bytes have been removed from buffer
+   * @return message number when message found, 0 otherwise
+   */
+  int GetMessage(void);
+  /**
+   * Extract data from old 1001-1004 RTCM3 messages.
+   * @param buffer the buffer containing an 1001-1004 RTCM block
+   * @param bufLen the length of the buffer (the message length including header+crc)
+   * @return <code>true</code> when data block is finished and transfered into
+   * {@link GPSDecoder::_obsList} variable
+   * @see DecodeRTCM3GLONASS()
+   * @see DecodeRTCM3MSM()
+   */
+  bool DecodeRTCM3GPS(unsigned char* buffer, int bufLen);
+  /**
+   * Extract data from old 1009-1012 RTCM3 messages.
+   * @param buffer the buffer containing an 1009-1012 RTCM block
+   * @param bufLen the length of the buffer (the message length including header+crc)
+   * @return <code>true</code> when data block is finished and transfered into
+   * {@link GPSDecoder::_obsList} variable
+   * @see DecodeRTCM3GPS()
+   * @see DecodeRTCM3MSM()
+   */
+  bool DecodeRTCM3GLONASS(unsigned char* buffer, int bufLen);
+  /**
+   * Extract data from MSM 1070-1229 RTCM3 messages.
+   * @param buffer the buffer containing an 1070-1229 RTCM block
+   * @param bufLen the length of the buffer (the message length including header+crc)
+   * @return <code>true</code> when data block is finished and transfered into
+   * {@link GPSDecoder::_obsList} variable
+   * @see DecodeRTCM3GPS()
+   * @see DecodeRTCM3GLONASS()
+   */
+  bool DecodeRTCM3MSM(unsigned char* buffer, int bufLen);
+  /**
+   * Extract ephemeris data from 1019 RTCM3 messages.
+   * @param buffer the buffer containing an 1019 RTCM block
+   * @param bufLen the length of the buffer (the message length including header+crc)
+   * @return <code>true</code> when data block was decodable
+   */
+  bool DecodeGPSEphemeris(unsigned char* buffer, int bufLen);
+  /**
+   * Extract ephemeris data from 1020 RTCM3 messages.
+   * @param buffer the buffer containing an 1020 RTCM block
+   * @param bufLen the length of the buffer (the message length including header+crc)
+   * @return <code>true</code> when data block was decodable
+   */
+  bool DecodeGLONASSEphemeris(unsigned char* buffer, int bufLen);
+  /**
+   * Extract ephemeris data from 1043 RTCM3 messages.
+   * @param buffer the buffer containing an 1043 RTCM block
+   * @param bufLen the length of the buffer (the message length including header+crc)
+   * @return <code>true</code> when data block was decodable
+   */
+  bool DecodeSBASEphemeris(unsigned char* buffer, int bufLen);
+  /**
+   * Extract ephemeris data from 1044 RTCM3 messages.
+   * @param buffer the buffer containing an 1044 RTCM block
+   * @param bufLen the length of the buffer (the message length including header+crc)
+   * @return <code>true</code> when data block was decodable
+   */
+  bool DecodeQZSSEphemeris(unsigned char* buffer, int bufLen);
+  /**
+   * Extract ephemeris data from 1045 and 1046 RTCM3 messages.
+   * @param buffer the buffer containing an 1045 and 1046 RTCM block
+   * @param bufLen the length of the buffer (the message length including header+crc)
+   * @return <code>true</code> when data block was decodable
+   */
+  bool DecodeGalileoEphemeris(unsigned char* buffer, int bufLen);
+  /**
+   * Extract ephemeris data from BDS RTCM3 messages.
+   * @param buffer the buffer containing an BDS RTCM block
+   * @param bufLen the length of the buffer (the message length including header+crc)
+   * @return <code>true</code> when data block was decodable
+   */
+  bool DecodeBDSEphemeris(unsigned char* buffer, int bufLen);
+  /**
+   * Extract antenna type from 1007, 1008 or 1033 RTCM3 messages.
+   * @param buffer the buffer containing an antenna RTCM block
+   * @param bufLen the length of the buffer (the message length including header+crc)
+   * @return <code>true</code> when data block was decodable
+   */
+  bool DecodeAntenna(unsigned char* buffer, int bufLen);
+  /**
+   * Extract antenna type from 1005 or 1006 RTCM3 messages.
+   * @param buffer the buffer containing an antenna RTCM block
+   * @param bufLen the length of the buffer (the message length including header+crc)
+   * @return <code>true</code> when data block was decodable
+   */
+  bool DecodeAntennaPosition(unsigned char* buffer, int bufLen);
 
+  /** Current station description, dynamic in case of raw input file handling */
   QString                _staID;
-  QString                _checkMountPoint;
-  QMap<QByteArray, RTCM3ParserData> _parsers;
-  QMap<QByteArray, RTCM3coDecoder*> _coDecoders; 
-  t_mode                 _mode;
-
-  double                 _antXYZ[3];
+  /** Raw input file for post processing, required to extract station ID */
   bncRawFile*            _rawFile;
 
-  QMap<QString, int>  _slip_cnt_L1;
-  QMap<QString, int>  _slip_cnt_L2;
-  QMap<QString, int>  _slip_cnt_L5;
+  /** List of decoders for Clock and Orbit data */
+  QMap<QByteArray, RTCM3coDecoder*> _coDecoders; 
+
+  /** Message buffer for input parsing */
+  unsigned char _Message[2048];
+  /** Current size of the message buffer */
+  size_t _MessageSize;
+  /** Minimum bytes required to have success during next {@link GetMessage()} call */
+  size_t _NeedBytes;
+  /** Bytes to skip in next {@link GetMessage()} call, intrnal to that function */
+  size_t _SkipBytes;
+  /** Size of the current RTCM3 block beginning at buffer start after a successful
+   *  {@link GetMessage()} call
+   */
+  size_t _BlockSize;
+
+  /**
+   * Current observation epoch. Used to link together blocks in one epoch.
+   */
+  bncTime _CurrentTime;
+  /** Current observation data block list, Filled by {@link DecodeRTCM3GPS()},
+   * {@link DecodeRTCM3GLONASS()} and {@link DecodeRTCM3MSM()} functions.
+   */
+  QList<t_satObs> _CurrentObsList;
 };
 
