Index: /trunk/BNC/RTIGS/RTIGSDecoder.cpp
===================================================================
--- /trunk/BNC/RTIGS/RTIGSDecoder.cpp	(revision 293)
+++ /trunk/BNC/RTIGS/RTIGSDecoder.cpp	(revision 293)
@@ -0,0 +1,105 @@
+
+/* -------------------------------------------------------------------------
+ * BKG NTRIP Client
+ * -------------------------------------------------------------------------
+ *
+ * Class:      RTIGSDecoder
+ *
+ * Purpose:    RTIGS Decoder
+ *
+ * Author:     L. Mervart
+ *
+ * Created:    24-Aug-2006
+ *
+ * Changes:    
+ *
+ * -----------------------------------------------------------------------*/
+
+#include "RTIGSDecoder.h"
+#include "bncconst.h"
+#include "rtigs.h"
+
+using namespace std;
+
+// Constructor
+////////////////////////////////////////////////////////////////////////////
+RTIGSDecoder::RTIGSDecoder() {
+}
+
+// Destructor
+////////////////////////////////////////////////////////////////////////////
+RTIGSDecoder::~RTIGSDecoder() {
+}
+
+// 
+////////////////////////////////////////////////////////////////////////////
+void RTIGSDecoder::Decode(char* buffer, int bufLen) {
+
+  // Append the incomming data to the internal buffer
+  // ------------------------------------------------
+  _buffer.append( QByteArray(buffer, bufLen) );
+
+  // Find the beginning of the message
+  // ---------------------------------
+  bool found = false;
+  for (int ii = 0; ii < _buffer.size(); ii++) { 
+    unsigned short xx;
+    memcpy( (void*) &xx, &_buffer.data()[ii], sizeof(xx) );
+    revbytes( (unsigned char*) &xx, sizeof(xx) );
+    if (xx == 200) {
+      _buffer = _buffer.mid(ii);
+      found = true;
+      break;
+    }
+  }
+  if (! found) {
+    _buffer.clear();
+    return;
+  }
+
+  // Read the Header
+  // ---------------
+  if (_buffer.size() < (int) sizeof(RTIGSH)) {
+    return;
+  }
+  RTIGSH rtigs_header;
+  bytes_to_rtigsh(&rtigs_header, (unsigned char*) _buffer.data());
+
+  // Read the Observations
+  // ---------------------
+  int numBytes = sizeof(RTIGSH) + rtigs_header.num_bytes;
+  if (_buffer.size() < numBytes) {
+    return;
+  }
+
+  if (rtigs_header.rec_id == 200) {
+    RTIGSO rtigs_obs;
+    memcpy(&rtigs_obs, &rtigs_header, sizeof(RTIGSH));
+    memcpy((unsigned char*) &rtigs_obs.data, _buffer.data(), 
+           rtigs_header.num_bytes - sizeof(RTIGSH));
+
+    GPSEpoch epoch;
+    rtigso_to_raw(&rtigs_obs, &epoch);
+
+    for (short ii = 0; ii < epoch.num_sv; ii++) {
+      Observation* obs = new Observation();
+
+      obs->SVPRN    = epoch.sv[ii].prn;
+      obs->GPSWeek  = epoch.GPSTime / (7 * 86400);
+      obs->GPSWeeks = epoch.GPSTime % (7 * 86400);
+      obs->C1       = epoch.sv[ii].CARange;
+      obs->P1       = epoch.sv[ii].P1Range;
+      obs->P2       = epoch.sv[ii].P2Range;
+      obs->L1       = epoch.sv[ii].L1Phase;
+      obs->L2       = epoch.sv[ii].L2Phase;
+      obs->SNR1     = int(epoch.sv[ii].L1Snr * 10);
+      obs->SNR2     = int(epoch.sv[ii].L2Snr * 10);
+
+      _obsList.push_back(obs);
+    }
+  }
+
+  // Unprocessed bytes remain in buffer
+  // ----------------------------------
+  _buffer = _buffer.mid(numBytes);
+}
Index: /trunk/BNC/RTIGS/RTIGSDecoder.h
===================================================================
--- /trunk/BNC/RTIGS/RTIGSDecoder.h	(revision 293)
+++ /trunk/BNC/RTIGS/RTIGSDecoder.h	(revision 293)
@@ -0,0 +1,18 @@
+
+#ifndef RTIGSDECODER_H
+#define RTIGSDECODER_H
+
+#include <QByteArray>
+
+#include "../RTCM/GPSDecoder.h"
+
+class RTIGSDecoder : public GPSDecoder {
+public:
+  RTIGSDecoder();
+  ~RTIGSDecoder();
+  void Decode(char* buffer = 0, int bufLen = 0);
+private:
+  QByteArray _buffer;
+} ;
+
+#endif
Index: unk/BNC/RTIGS/cgps_transform.cpp
===================================================================
--- /trunk/BNC/RTIGS/cgps_transform.cpp	(revision 292)
+++ 	(revision )
@@ -1,761 +1,0 @@
-#include "cgps_transform.h"
-
-#define MAXSTREAM 10000
-
-////////////////////////////////////////////////////////////////////////////
-void SwitchBytes( char *Start, int Size ) {
-  char Tmp;
-  char *End = Start + Size - 1;
-  for( Tmp = *Start; Start < End; Tmp = *Start ){
-    *Start++ = *End;
-    *End-- = Tmp;
-  }
-}
-
-#ifdef CGPS_TRANSFORM_MAIN
-int main() {
-
-  unsigned char  data_stream[MAXSTREAM];
-  unsigned short numbytes;
-  RTIGSS_T       rtigs_sta;
-  RTIGSO_T       rtigs_obs;
-  RTIGSM_T       rtigs_met;
-  RTIGSE_T       rtigs_eph;
-  short          PRN;
-  short          retval;
-  unsigned short statID;
-  unsigned short messType;
-  CGPS_Transform GPSTrans;
-
-  memset(data_stream , 0, sizeof(data_stream));
-
-  // use something like recvfrom 
-  FILE* inpFile = fopen("RTIGS.txt", "rb");
-
-  while (true) {
-    size_t nr = 0;
-   if (inpFile) {
-     nr = fread(data_stream, sizeof(unsigned char), MAXSTREAM, inpFile);
-     if (nr == 0) exit(0);
-     cout << "Number of bytes read: " << nr << endl;
-   }
-   else {
-     exit(1);
-   }
-  
-   // Find the beginning of the message
-   // ---------------------------------
-   size_t sz = sizeof(unsigned short);
-   bool   found = false;
-   size_t ii;
-   for (ii = 0; ii < nr - sz; ii += sz) {
-     unsigned short xx;
-     memcpy( (void*) &xx, &data_stream[ii], sz);
-     SwitchBytes( (char*) &xx, sz);
-     if (xx == 200) {
-       found = true;
-       break;
-     }
-   }
-   if (! found) {
-     cout << "Message not found\n";
-     exit(0);
-   }
-   else {
-     cout << "Message found at " << ii << endl;
-   }
-
-
-   messType = GPSTrans.GetRTIGSHdrRecType(&data_stream[ii]);
-   numbytes = GPSTrans.GetRTIGSHdrRecBytes(&data_stream[ii]);
-   statID   = GPSTrans.GetRTIGSHdrStaID(&data_stream[ii]);
-
-   cout << "messType " << messType << endl;
-   cout << "numbytes " << numbytes << endl;
-   cout << "statID "   << statID   << endl;
-
-   switch (messType) {
-   case 100:
-     GPSTrans.Decode_RTIGS_Sta(&data_stream[ii], numbytes , rtigs_sta);
-     break;
-   case 200:
-     retval = GPSTrans.Decode_RTIGS_Obs(&data_stream[ii], numbytes , rtigs_obs);
-     if (retval >= 1) {
-       GPSTrans.print_CMEAS();
-     }
-     break;
-   case 300:
-     retval = GPSTrans.Decode_RTIGS_Eph(&data_stream[ii], numbytes , rtigs_eph, PRN);
-     break;
-   case 400:
-     retval = GPSTrans.Decode_RTIGS_Met(&data_stream[ii], numbytes , &rtigs_met); 
-     break;
-   }
-  }
-
-  return 0;
-}
-#endif
-
-// Constructor
-////////////////////////////////////////////////////////////////////////////
-CGPS_Transform::CGPS_Transform() {
-
-  // Decoded Obs Array of 12 CMeas Observation Records
-  memset((void *)&DecObs, 0, sizeof(ARR_OBS_T     ));
-
-  // Keplarian Broadcast Eph
-  memset((void *)&TNAV_Eph,0, sizeof(ARR_TNAV_T   ));
-
-  NumObsRead = -1;
-  CAFlag = -1;
-  ASFlag = -1;
-  P2Flag = -1;
-  P1Flag = -1;
-  InitEndianFlag();
-
-  memset (PhaseArcStartTime, 0, sizeof(PhaseArcStartTime));
-}
-
-// Destructor
-////////////////////////////////////////////////////////////////////////////
-CGPS_Transform::~CGPS_Transform() {
-}
-
-// 
-////////////////////////////////////////////////////////////////////////////
-unsigned short CGPS_Transform::GetRTIGSHdrRecType(unsigned char *RTIGS_Str)
-{
-        unsigned short recordID;
-        memcpy ((void *)&recordID,RTIGS_Str, sizeof(recordID));
-        if (f_IsLittleEndian)
-        {
-                SwitchBytes( (char *)&recordID, sizeof(recordID) );
-        }
-        return recordID;
-}
-
-// 
-////////////////////////////////////////////////////////////////////////////
-unsigned short CGPS_Transform::GetRTIGSHdrRecBytes(unsigned char *RTIGS_Str)
-{
-        unsigned short bytes;
-        memcpy ((void *)&bytes,&RTIGS_Str[8], sizeof(bytes));
-        if (f_IsLittleEndian)
-        {
-                SwitchBytes( (char *)&bytes, sizeof(bytes) );
-        }
-        return bytes;
-
-}
-
-// 
-////////////////////////////////////////////////////////////////////////////
-unsigned short CGPS_Transform::GetRTIGSHdrStaID(unsigned char *RTIGS_Str)
-{
-        unsigned short StaID = 0;
-        memcpy ((void *)&StaID, &RTIGS_Str[2], sizeof(StaID));
-        if (f_IsLittleEndian)
-        {
-                SwitchBytes( (char *)&StaID, sizeof(StaID) );
-        }
-        return StaID;
-}
-
-
-// 
-////////////////////////////////////////////////////////////////////////////
-void CGPS_Transform::InitEndianFlag() {
-  short one = 1;
-  char *cp = (char *)&one;
-  if (*cp== 0) {
-    f_IsLittleEndian = false;
-  }
-  else {
-    f_IsLittleEndian = true;
-  }
-}
-
-
-// 
-////////////////////////////////////////////////////////////////////////////
-unsigned long  CGPS_Transform::JPL_xtractLongVal (unsigned startBitNbr, unsigned xtractNbrBits, const char *msg)
-{
-  unsigned long    retValue=0, i=0;
-
-  unsigned short posBit     = xtractNbrBits - 1;
-
-  for(i=0; i<xtractNbrBits; i++, startBitNbr++)
-    {
-    unsigned short numShift   = 7 - (startBitNbr % 8);
-    unsigned short byteNbr    = startBitNbr / 8;
-    retValue     |= (((msg[byteNbr] >> numShift) & 0x0001) << posBit--);
-
-    }
-
-  return retValue;
-}
-
-// 
-////////////////////////////////////////////////////////////////////////////
-inline void   CGPS_Transform::SwitchIGS_Sta_HdrBytes( RTIGSS_T *StaHdr)
-{
-  SwitchBytes( (char *)&StaHdr->GPSTime, sizeof(unsigned long) );
-  SwitchBytes( (char *)&StaHdr->num_bytes, sizeof(unsigned short) );
-  SwitchBytes( (char *)&StaHdr->rec_id, sizeof(unsigned short) );
-  SwitchBytes( (char *)&StaHdr->sta_id, sizeof(unsigned short) );
-}
-
-// 
-////////////////////////////////////////////////////////////////////////////
-inline void  CGPS_Transform::SwitchIGS_Obs_HdrBytes( RTIGSO_T *ObsHdr)
-{
-  SwitchBytes( (char *)&ObsHdr->GPSTime, sizeof(unsigned long) );
-  SwitchBytes( (char *)&ObsHdr->num_bytes, sizeof(unsigned short) );
-  SwitchBytes( (char *)&ObsHdr->rec_id, sizeof(unsigned short) );       
-  SwitchBytes( (char *)&ObsHdr->sta_id, sizeof(unsigned short) );
-}
-
-// 
-////////////////////////////////////////////////////////////////////////////
-inline void  CGPS_Transform::SwitchIGS_Eph_HdrBytes( RTIGSE_T *EphHdr)
-
-{
-  SwitchBytes( (char *)&EphHdr->CollectedGPSTime, sizeof(unsigned long) );
-  SwitchBytes( (char *)&EphHdr->num_bytes, sizeof(unsigned short) );
-  SwitchBytes( (char *)&EphHdr->rec_id, sizeof(unsigned short) );
-  SwitchBytes( (char *)&EphHdr->sta_id, sizeof(unsigned short) );
-}
-
-// 
-////////////////////////////////////////////////////////////////////////////
-inline short  CGPS_Transform::SwitchIGS_Met_RecBytes( RTIGSM_T *MetHdr)
-{
-short retval = 1;
-short i, num_items;
-  num_items = (short)MetHdr->numobs;
-  SwitchBytes( (char *)&MetHdr->GPSTime, sizeof(unsigned long) );
-  SwitchBytes( (char *)&MetHdr->num_bytes, sizeof(unsigned short) );
-  SwitchBytes( (char *)&MetHdr->rec_id, sizeof(unsigned short) );
-  SwitchBytes( (char *)&MetHdr->sta_id, sizeof(unsigned short) );
-
-    /*switch met data bytes*/       
-  for (i=0; i < num_items; i++)
-  {
-    if (&MetHdr->mets[i] != NULL)
-    {
-      SwitchBytes( (char *)&MetHdr->mets[i], sizeof(long) );
-    }
-    else
-    {
-      retval = -1;
-    }
-
-  }
-return retval;
-}
-// 
-////////////////////////////////////////////////////////////////////////////
-
-short CGPS_Transform::Save_TNAV_T_To_Container(TNAV_T *rtcurrent_eph, short &prn)
-{
-short retval = 1;//, i;
-long PRN;
-
-  PRN = rtcurrent_eph->Satellite;
-
-  if (f_IsLittleEndian)
-  {       
-    SwitchBytes( (char *)&PRN, sizeof(PRN));
-  }
-
-  if ((PRN > 0) && (PRN <= 32))
-  {
-    memcpy( (void *)&TNAV_Eph.Eph[(PRN-1)]  ,rtcurrent_eph,sizeof(TNAV_T));
-    prn = (short)PRN;
-  }
-  else
-  {
-    retval = -1;
-  }
-return retval;
-}
-
-//
-////////////////////////////////////////////////////////////////////////////
-short CGPS_Transform::CA_Extract(char * CAStr, double &CA_Rng)
-{
-
-
-unsigned long CARng2, CARng1;
-short retval = 0;
-double dtemp;
-
-
-  CGPS_Transform::CAFlag = JPL_xtractLongVal(0, 1,  CAStr);       
-  CGPS_Transform::ASFlag = JPL_xtractLongVal(1, 1,  CAStr);       
-  CGPS_Transform::P2Flag = JPL_xtractLongVal(2, 1,  CAStr);       
-  CGPS_Transform::P1Flag = JPL_xtractLongVal(3, 1,  CAStr);
-
-  if (CAFlag)
-  {
-      //Read most significant bits  
-    CARng2 = JPL_xtractLongVal(4, 4,  CAStr);   
-      //Read an int's worth of data
-    CARng1 = JPL_xtractLongVal (8,32,CAStr);
-//  if (f_IsLittleEndian == false)
-//  {
-      //KML June 8/2004
-      //Added this code to deal with Big Endian architectures     
-//    SwitchBytes( (char *) &CARng2, sizeof(CARng2) );
-//    SwitchBytes( (char *) &CARng1, sizeof(CARng1) );
-//  }
-
-    dtemp = 0.0;
-    dtemp = CARng2;
-
-    CA_Rng = dtemp*pow ((double)2,32);
-    CA_Rng +=       CARng1;
-
-    CA_Rng /= 1000;   //CA in metres
-  }
-  else
-  {
-    retval = -1;
-  }
-return retval;
-}
-
-// 
-////////////////////////////////////////////////////////////////////////////
-short CGPS_Transform::P1_P2_Block_Extract(char * P1P2Str, double CA, double &Rng , double &Phase, double &RngF2Delta,short decode_F1orF2Flag )
-{
-short retval =0;
-short PhaseOverFlowFlag;
-long SignFlag,temp;
-
-double RngDelta, PhaseDelta;
-
-  if (decode_F1orF2Flag == 1)
-  {
-    PhaseOverFlowFlag = CGPS_Transform::P1Flag;
-  }
-  else if (decode_F1orF2Flag == 2)
-  {
-    PhaseOverFlowFlag = CGPS_Transform::P2Flag;
-  }
-    //*****************************
-    // Decode Pseudo Range
-    //*****************************
-  SignFlag = JPL_xtractLongVal (0,1,P1P2Str);
-  temp = JPL_xtractLongVal (1,17,P1P2Str);
-
-//KML June 8/2004
-//      if (f_IsLittleEndian == false)
-//      {
-  //Added this code to deal with Big Endian architectures
-//  SwitchBytes( (char *) &temp, sizeof(temp) );
-//      }
-
-
-  RngDelta = temp;
-  RngDelta /= 1000.0;
-
-
-  if (SignFlag)
-  {
-    RngDelta *= -1;       
-  }
-
-
-  if (decode_F1orF2Flag == 2)
-  {
-    RngF2Delta = RngDelta;
-  }
-
-  Rng = CA +  RngDelta;
-
-    //***************************
-    // Decode Phase
-    //***************************
-
-  SignFlag = JPL_xtractLongVal (18,1, P1P2Str);
-  temp = JPL_xtractLongVal (19,21, P1P2Str);
-//      if (f_IsLittleEndian == false)
-//      {
-
-  //KML June 8th 2004
-  //Added this code to deal with Big Endian architectures
-//  SwitchBytes( (char *) &temp, sizeof(temp) );
-//      }
-
-  PhaseDelta =    temp;
-
-  PhaseDelta =    PhaseDelta * 2 / 100000;
-
-
-
-
-    //Phase overflow add to phase
-  if(PhaseOverFlowFlag)
-  {
-    PhaseDelta += MAXL1L2;
-  }
-
-  if (SignFlag)
-  {
-    PhaseDelta *= -1;       
-  }
-
-  if (decode_F1orF2Flag == 1)
-  {
-    // frequency 1
-    Phase = (CA - (ScaleFactor2*RngF2Delta)+ PhaseDelta) / L1;
-  }
-  else if (decode_F1orF2Flag == 2)
-  {
-    // frequency 2      
-    Phase = (CA - (ScaleFactor1*RngF2Delta)+ PhaseDelta) / L2;
-  }
-  else
-  {
-    retval =-1;
-  }
-return retval;
-}
-
-// 
-////////////////////////////////////////////////////////////////////////////
-short CGPS_Transform::Decode_RTIGS_Sta(unsigned char *RTIGS_Str,  unsigned short RTIGS_Bytes, RTIGSS_T &rtigs_sta)
-{
-short retval = 1;
-  memcpy ((void *)&rtigs_sta.rec_id, &RTIGS_Str[0], (sizeof(RTIGSS_T) - sizeof(rtigs_sta.data)));
-  if (f_IsLittleEndian)
-  {
-    SwitchIGS_Sta_HdrBytes( &rtigs_sta);
-  }
-  if (rtigs_sta.rec_id == 100)
-  {
-    if (rtigs_sta.sta_rec_type ==0 )
-    {
-      rtigs_sta.data = NULL;      
-    }
-    else
-    {
-      retval = -2;    //no other type supported at this time
-    }
-  }
-
-
-  else
-  {
-
-
-    retval = -1;
-
-  }
-
-return retval ;
-}
-
-// 
-////////////////////////////////////////////////////////////////////////////
-short CGPS_Transform::Decode_RTIGS_Soc_Obs(unsigned char *SocStr,  short &StrPos, short CMeasIndex, short SocBytes, unsigned long GPSTime)
-{
-short retval =1;
-double CA,  RngF2Delta,  PhaseL1,PhaseL2, P1, P2;
-//static unsigned short PhaseArcStartTime[MAXSV]; moved to class header
-JPL_COMP_OBS_T GPSObs;
-//printf("String pos %hd Total Bytes %hd\n", StrPos,SocBytes);
-
-  if ((StrPos <= SocBytes) && ((CMeasIndex >= 0 ) &&  (CMeasIndex < MAXSV )))
-  {
-    
-    memcpy((void *)&GPSObs.prn, (void *)&SocStr[StrPos], 1);
-
-    if ((GPSObs.prn > 0 ) && (GPSObs.prn <= 32))
-    {
-      StrPos+=1;
-
-      memcpy((void *)&GPSObs.epoch_sequence, (void *)&SocStr[StrPos],2);
-
-      if (f_IsLittleEndian == false)
-      {
-  //KML June 8/2003
-  //Added this code to deal with Big Endian architectures
-  SwitchBytes( (char *) &GPSObs.epoch_sequence, sizeof(GPSObs.epoch_sequence) );
-      }
-
-    //******************************
-    // Read and decode CA
-    //******************************
-      StrPos+=2;
-      memcpy((void *)&GPSObs.ca_range, (void *)&SocStr[StrPos],5);
-      CA_Extract(GPSObs.ca_range, CA);
-
-      if (CGPS_Transform::CAFlag)       //Defined in the Class by CA_Extract
-      {
-    //************************************
-    // Read CA SNR
-    //************************************
-  StrPos+=5;
-  memcpy((void *)&GPSObs.CA_snr, (void *)&SocStr[StrPos],1);
-    //************************************
-    // Read and decode P2 L2
-    //************************************
-  StrPos+=1;
-  memcpy((void *)&GPSObs.L2_range_phase, (void *)&SocStr[StrPos],5);
-
-  P1_P2_Block_Extract(GPSObs.L2_range_phase,  CA, P2 , PhaseL2, RngF2Delta, 2 );
-
-
-  StrPos+=5;
-  memcpy((void *)&GPSObs.L2_snr, (void *)&SocStr[StrPos],1);
-      //************************************
-      // Read and decode P1 L1
-      //************************************
-  StrPos+=1;
-
-
-  memcpy((void *)&GPSObs.L1_range_phase, (void *)&SocStr[StrPos],5);
-
-  P1_P2_Block_Extract(GPSObs.L1_range_phase, CA, P1, PhaseL1, RngF2Delta, 1);
-
-  StrPos+=5;
-  memcpy((void *)&GPSObs.L1_snr, (void *)&SocStr[StrPos],1);
-  StrPos+=1;
-
-  DecObs.Obs[CMeasIndex].GPSTime = GPSTime;    /* broadcast time sec.*/
-  DecObs.Obs[CMeasIndex].chn = CMeasIndex + 1; /* Channel not real*/
-  DecObs.Obs[CMeasIndex].sat_prn = GPSObs.prn; /* satellite ID*/
-  DecObs.Obs[CMeasIndex].ntrvl = 1;      /* number of seconds Changed from 0 to 1 Nov. 25/2003*/
-  DecObs.Obs[CMeasIndex].flag[0] = 4;    /*observation quality flags*/   //KML Changed Nov. 25/2000 to 4 to indicate Benchmark
-
-  if (PhaseArcStartTime[(short)(GPSObs.prn-1)] !=  GPSObs.epoch_sequence)
-  {
-    PhaseArcStartTime[(short)(GPSObs.prn-1)] =  GPSObs.epoch_sequence;
-    DecObs.Obs[CMeasIndex].flag[0] |= 0x20;
-  }
-
-  DecObs.Obs[CMeasIndex].l1_pseudo_range = CA;      /* frequency-1 CA pseudorange */
-  DecObs.Obs[CMeasIndex].l1_phase = PhaseL1;      /* frequency-1 CA carrier phase   */
-      //****************************************************
-      // Changed SNR Ashtech to DBHz Nov 15/2002
-      //****************************************************
-  DecObs.Obs[CMeasIndex].l1_sn  =  GPSObs.CA_snr;
-
-  DecObs.Obs[CMeasIndex].p1_pseudo_range = P1;  /* frequency-1 P1 carrier phase   */
-  DecObs.Obs[CMeasIndex].p1_phase  =  PhaseL1;    /* frequency-1 P1 pseudorange */
-
-  DecObs.Obs[CMeasIndex].p1_sn = GPSObs.L1_snr;
-
-  DecObs.Obs[CMeasIndex].l2_pseudo_range = P2;    /* frequency-2 pseudorange (XCorr) */
-  DecObs.Obs[CMeasIndex].l2_phase = PhaseL2;  /* frequency-2 carrier phase (XCorr)  */
-
-  DecObs.Obs[CMeasIndex].l2_sn = GPSObs.L2_snr;
-  DecObs.Obs[CMeasIndex].p2_pseudo_range  = P2;       /* frequency-2 pseudorange     */
-  DecObs.Obs[CMeasIndex].p2_phase = PhaseL2;      /* frequency-2 carrier phase   */
-      }
-      else
-      {
-      //skip this obs
-  DecObs.Obs[CMeasIndex].sat_prn = 0;
-      }
-    }
-    else
-    {
-      retval = -2;
-
-    }
-  }
-  else
-  {
-    retval = -1;
-  }
-return retval;
-}
-
-// 
-////////////////////////////////////////////////////////////////////////////
-short CGPS_Transform::RTIGSO_Str_To_CMEAS(unsigned char *RTIGSO_Str, short RTIGS_Bytes, RTIGSO_T &rtigs_obs)
-{
-short retval =1,i, StrPos;//, HdrRetval;
-//short  NumObs= 0;
-short decoded_cnt = 0;
-short  IGSObsMinusPtr;
-
-
-  //************************************
-  // Zero out CMEAS_T container
-  //************************************
-memset((void *)&DecObs.Obs[0], 0 , sizeof(ARR_OBS_T) );
-
-    //***********************************************
-    // Decode Header store in class container
-    //***********************************************
-
-
-  StrPos = IGSObsMinusPtr = sizeof(RTIGSO_T) - sizeof (rtigs_obs.data);
-
-  ////  cout << "StrPos " << StrPos << endl;
-
-  memcpy ((void *)&rtigs_obs.rec_id, RTIGSO_Str, IGSObsMinusPtr);
-
-  if (f_IsLittleEndian)
-  {
-    SwitchIGS_Obs_HdrBytes( &rtigs_obs);
-  }
-
-
-  // printf("RecNumber : %hd Station ID %hd Num Obs %hd NumBytes %hd\n",rtigs_obs.rec_id, rtigs_obs.sta_id, rtigs_obs.num_obs, rtigs_obs.num_bytes);
-
-  if((rtigs_obs.rec_id == 200) && (rtigs_obs.num_obs <= MAXCHANNELS_FOR_SOCKETS_TYPE1))
-  {
-    for (i = 0 ; i < rtigs_obs.num_obs;i++)
-    {
-    //*********************************************
-    // the following function decodes the soc
-    // structure and writes the obs to the
-    // class's CMEAS container
-    //*********************************************
-
-      if (Decode_RTIGS_Soc_Obs( RTIGSO_Str, StrPos, decoded_cnt, RTIGS_Bytes, rtigs_obs.GPSTime) < 0)
-      {
-    retval = -2;
-      }
-      else
-      {
-  decoded_cnt ++;
-      }
-    }//end of for
-    retval = NumObsRead = decoded_cnt; //NumObsRead class member
-  }
-  else
-  {
-    retval = -1;
-  }
-//ObsSeqNum++;
-return retval;
-}
-
-
-// 
-////////////////////////////////////////////////////////////////////////////
-short CGPS_Transform::Decode_RTIGS_Obs(unsigned char *RTIGSO_Str,  unsigned short RTIGS_Bytes,RTIGSO_T &rtigs_obs)
-{
-  short retval = 1;//, i;
-
-
-  if ((retval = RTIGSO_Str_To_CMEAS(RTIGSO_Str, RTIGS_Bytes, rtigs_obs)) < 0)
-  {
-    retval = -1;
-  }
-
-return retval;
-}
-
-// 
-////////////////////////////////////////////////////////////////////////////
-short  CGPS_Transform::Decode_RTIGS_Met(unsigned char *RTIGS_Str,  unsigned short RTIGS_Bytes, RTIGSM_T *rtigs_met)
-{
-short retval = 1;
-short numbytes = 0;
-numbytes = sizeof(RTIGSM_T) -  sizeof(rtigs_met->mets);
-memcpy ((void *)rtigs_met, RTIGS_Str, numbytes);
-
-    if ((short)rtigs_met->numobs <= 3)
-  {
-    if (rtigs_met->mets != NULL)
-    {
-      memcpy ((void *)&rtigs_met->mets[0], &RTIGS_Str[numbytes], ((short)rtigs_met->numobs * sizeof(long)) );
-      if (f_IsLittleEndian)
-      {
-  SwitchIGS_Met_RecBytes( rtigs_met);
-      }
-      if (rtigs_met->rec_id != 400)
-      {
-  retval = -1;
-      }
-    }
-    else
-    {
-      retval = -2;
-      delete [] rtigs_met->mets;
-    }
-  }
-  else
-  {
-    printf("failed number of Obs\n");
-  }
-
-return retval;
-}
-
-// 
-////////////////////////////////////////////////////////////////////////////
-short CGPS_Transform::Decode_RTIGS_Eph(unsigned char *RTIGS_Str,  unsigned short RTIGS_Bytes, RTIGSE_T &rtigs_eph, short &PRN)
-{
-  short retval = 1;//, i;
-  short  index = 0;
-  short prn;
-  const short SubFrameSize = 24;
-  TNAV_T trans_eph;
-  index = sizeof(RTIGSE_T ) - sizeof (rtigs_eph.data);
-
-  memcpy ((void *)&rtigs_eph.rec_id, &RTIGS_Str[0], index);       //copy header into struct from string
-  if (f_IsLittleEndian)
-  {
-    SwitchIGS_Eph_HdrBytes( &rtigs_eph);
-  }
-
-  if (rtigs_eph.rec_id == 300)
-  {
-    //*********************************************
-    // the following method saves the eph
-    // in the class's TNAV_T container
-    //*********************************************
-    trans_eph.GPSCollectedTime =    rtigs_eph.CollectedGPSTime;
-    trans_eph. Satellite = (long)rtigs_eph.prn;
-    //********************************************
-    // Container class is in network byte order
-    //********************************************
-    if (f_IsLittleEndian)
-    {
-      SwitchBytes( (char *)&trans_eph.GPSCollectedTime, sizeof(trans_eph.GPSCollectedTime) );
-      SwitchBytes( (char *)&trans_eph. Satellite, sizeof(trans_eph. Satellite) );
-    }
-
-    memcpy((void *)&trans_eph.SubFrame1, (const void *)&RTIGS_Str[index], SubFrameSize);
-    memcpy((void *)&trans_eph.SubFrame2, (const void *)&RTIGS_Str[(index + SubFrameSize)], SubFrameSize);
-    memcpy((void *)&trans_eph.SubFrame3, (const void *)&RTIGS_Str[(index + (SubFrameSize * 2)) ], SubFrameSize);
-    if (Save_TNAV_T_To_Container(&trans_eph, prn) >= 1)       //function saves eph in container and returns prn
-    {
-  PRN = prn;
-    }
-    else
-    {
-      retval = -1;
-    }
-  }
-  else
-  {
-    retval = -1;
-  }
-
-return retval;
-}
-
-void CGPS_Transform::print_CMEAS()
-{
-short i;
-        printf("\nGPSTime   SV    CA      SNR     P1      SNR     P2      SNR\n");
-        printf("Seconds         (m)     DBHz    (m)     DBHz    (m)     DBHz\n");
-        for (i=0; i < NumObsRead ; i++)
-        {
-                printf("%ld %2hd %10.1lf %4.1f %10.1lf %4.1f %10.1lf %4.1f \n",DecObs.Obs[i].GPSTime, DecObs.Obs[i].sat_prn,
-                                                                                DecObs.Obs[i].l1_pseudo_range,DecObs.Obs[i].l1_sn,
-                                                                                DecObs.Obs[i].p1_pseudo_range, DecObs.Obs[i].p1_sn,
-                                                                                DecObs.Obs[i].l2_pseudo_range,DecObs.Obs[i].l2_sn);
-        }
-}
-
Index: unk/BNC/RTIGS/cgps_transform.h
===================================================================
--- /trunk/BNC/RTIGS/cgps_transform.h	(revision 292)
+++ 	(revision )
@@ -1,127 +1,0 @@
-
-#ifndef CGPS_TRANSFORM_H
-#define CGPS_TRANSFORM_H
-
-#include <string.h>
-#include <stdio.h>
-#include <math.h>
-#include <sys/time.h>
-#include <iostream>
-
-using namespace std;
-
-#include "rtacp.h"
-#include "rtstruct.h"
-#include "rtigs_records.h"
-
-#define MAXCHANNELS_FOR_SOCKETS_TYPE1 12
-#define MAXSV        32
-#define ScaleFactor1 4.0914555603263203   //(f1ion + f2ion)
-#define ScaleFactor2 2 * F1ION
-#define MAXL1L2      41.94302
-
-void SwitchBytes( char *Start, int Size );
-
-typedef struct
-{
-    unsigned char prn;       // satellite ID
-    unsigned short epoch_sequence; // like Ashtech seq number of phase epochs
-        // was like this, now modulo 10 hours,
-        // each digit is now 1 sec, not .05 secs like before
-
-    char ca_range[5];    // ca range in millimeters
-        // first 4 bits are status bits, as follows
-        // if bit 7 on, sucessful packing of ca_range
-        // if bit 6 on, Z track mode or AS is on
-        // if bit 5 on, overflow of L2_block phase
-        // if bit 4 on, overflow of L1_block phase
-        // next 36 bits are the observable
-        // 68719.476735 is the max allowable obsev.
-        // if not packed, L2_block and L1_block is
-        // just then packed with 0s
-
-    unsigned char CA_snr;  // receiver snr for ca in dbHz KML the SNR is (DBHz * 4.25) rounded to an int (max is 60.0)
-
-    char L2_range_phase[5];
-        // first 2 bytes and 2 bits is for the range, next 6 bits and 2 bytes are for phase.
-        //
-        // range units are in millimeters, from -131071 to 131071  (2^17 - 1)
-        // 0000 0000 0000 0000 01 would be +1 mm
-        // 1000 0000 0000 0000 01 would be -1 mm
-        // 0100 0000 0000 0000 00 would be 65536 mm
-        // 1100 0000 0000 0000 00 would be -65536 mm
-        // 0111 1111 1111 1111 11 would be 131071 mm
-        // 1111 1111 1111 1111 11 woule be -131071 mm
-        // dynamic range must be <= 131.071 meters
-        //
-        // phase units are in 2/100 millimeters from -4194304 to 4194304
-        // 00 0000 0000 0000 0000 0001 would be +.02 mm
-        // 10 0000 0000 0000 0000 0001 would be -.02 mm
-        // 01 1111 1111 1111 1111 1111 ( 2097151) would be 41943.02 mm
-        // 11 1111 1111 1111 1111 1111 (-2097151) would be -41943.02 mm
-        //   (2^21 - 1)*2 mm
-        // dynamic range must be <= 41.94302 meters
-        //
-        // note if the limits are exceded, a -0 (minus zero) is returned
-        // indicating not a number
-        //
-        // Note however, we extended this dynamic range to 83.88606 meters as
-        // below with the spare bits in the ca_range field. If this limit
-        // is exceeded we return a -0 ( minus zero )
-    unsigned char L2_snr;  // snr for this data type in dbHz KML the SNR is (DBHz * 4.25) rounded to an int (max is 60.0 )
-
-    char L1_range_phase[5]; // same as format for L2_range_phase
-
-    unsigned char L1_snr;  // snr for this data type in dbHz KML the SNR is (DBHz * 4.25) rounded to an int (max is 60.0 )
-
-} JPL_COMP_OBS_T;
-
-typedef struct
-{
-   TNAV_T   Eph[MAXSV];      //32 prns
-} ARR_TNAV_T;
-
-typedef struct {
-   CMEAS_T  Obs[MAXSV];   //32 obs
-} ARR_OBS_T ;
-
-class CGPS_Transform {
-friend class rtigs;
-private:
-  ARR_OBS_T     DecObs;
-  ARR_TNAV_T    TNAV_Eph;
-  short         NumObsRead;
-  short         CAFlag;
-  short          ASFlag;
-  short          P2Flag;
-  short          P1Flag;
-  bool           f_IsLittleEndian;
-  unsigned short PhaseArcStartTime[MAXSV];
-public:
-  CGPS_Transform();
-  ~CGPS_Transform();
-  void           InitEndianFlag();
-  short          Decode_Soc_Obs(unsigned char  *SocStr, short &StrIndex, short index, short SocBytes);
-  short          Decode_RTIGS_Soc_Obs(unsigned char *SocStr,  short &StrPos, short CMeasIndex, short SocBytes, unsigned long GPSTime);
-  short          RTIGSO_Str_To_CMEAS(unsigned char *RTIGSO_Str, short RTIGS_Bytes, RTIGSO_T &rtigs_obs); //done needs testing KML
-  void           print_CMEAS();
-  short          Save_TNAV_T_To_Container(TNAV_T *rtcurrent_eph, short &prn);
-  short          CA_Extract(char * CAStr, double &CA_Rng);                 //done
-  short          P1_P2_Block_Extract(char * P1P2Str, double CA, double &Rng , double &Phase, double &RngF2Delta,short decode_F1orF2Flag );//done
-  unsigned long  JPL_xtractLongVal (unsigned startBitNbr, unsigned xtractNbrBits, const char *msg);        //done
-  inline void    SwitchIGS_Sta_HdrBytes( RTIGSS_T *StaHdr);
-  inline void    SwitchIGS_Obs_HdrBytes( RTIGSO_T *ObsHdr);
-  inline void    SwitchIGS_Eph_HdrBytes( RTIGSE_T *EphHdr);
-  inline short   SwitchIGS_Met_RecBytes( RTIGSM_T *MetHdr);
-  unsigned short GetRTIGSHdrRecType(unsigned char *RTIGS_Str);
-  unsigned short GetRTIGSHdrStaID(unsigned char *RTIGS_Str);
-  unsigned short GetRTIGSHdrRecBytes(unsigned char *RTIGS_Str);
-  unsigned long  GetRTIGSHdrGPSSeconds(unsigned char *RTIGS_Str);
-  short          Decode_RTIGS_Sta(unsigned char *RTIGS_Str,   unsigned short RTIGS_Bytes, RTIGSS_T &rtigs_sta_dec);        // contents of record contain all info
-  short          Decode_RTIGS_Obs(unsigned char *RTIGS_Str,  unsigned  short RTIGS_Bytes, RTIGSO_T &rtigs_obs);    // stores obs in class container
-  short          Decode_RTIGS_Eph(unsigned char *RTIGS_Str,  unsigned  short RTIGS_Bytes, RTIGSE_T &rtigs_eph, short arrPRN[]);    // stores eph in class container
-  short          Decode_RTIGS_Eph(unsigned char *RTIGS_Str,  unsigned  short RTIGS_Bytes, RTIGSE_T &rtigs_eph, short &PRN); //stors in class and returns prn
-  short          Decode_RTIGS_Met(unsigned char *RTIGS_Str,   unsigned short RTIGS_Bytes, RTIGSM_T *rtigs_met);    // contents of record contain all info.
-};
-
-#endif
Index: unk/BNC/RTIGS/rtacp.h
===================================================================
--- /trunk/BNC/RTIGS/rtacp.h	(revision 292)
+++ 	(revision )
@@ -1,65 +1,0 @@
-/***************************************************************************
-                          rtacp.h  -  description
-                             -------------------
-    begin                : Mon Mar 27 2000
-    copyright            : (C) 2000 by Ken MacLeod
-    email                : macleod@geod.nrcan.gc.ca
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- ***************************************************************************/
-/* $Header: rtacp.h,v 3.1 99/06/08 15:59:45 lahaye Released $ */
-#ifndef _RTACP
-#define _RTACP
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <time.h>
-#include "rtstruct.h"
-#ifndef _RTAP
-//#include "GTT.h"
-#endif
-
-#define gps_start_second 0
-#define gps_end_second   1572480000
-
-#define DATA_RATE       1	/* data rate used in decimate */
-#define NUM_PTS         14	/* number of code points used in on either side */
-#define L_NUM_PTS       4	/* maximum number of phase points on either side for polynomial fit */
-#define L_ORDER         3      /* order of polynomial fit to phase */
-#define L2_L1_ORDER     3      /* order of polynomial fit to L2-L1 series */
-#define NSEC            30	/* decimation epoch */
-#define MIN_ELEV        10.0
-#define MAXGAP          600     /* gap in stats_l2_l1 function for reinitialization */
-					/* A B and C precise model values */
-
-#define PM_A   ( (154.0*154.0) + (120.0*120.0) ) / ( (154.0*154.0) - (120.0*120.0) )
-#define PM_B   ( 2.0 * (120.0*120.0) ) / ( (154.0*154.0) - (120.0*120.0) )
-#define PM_C   ( 2.0 * (154.0*154.0) ) / ( (154.0*154.0) - (120.0*120.0) )
-
-
-#define L1F            		(154.0 * 10.23e6)	/* L1 frequency */
-#define L2F            		(120.0 * 10.23e6)	/* L2 frequency */
-#define PCR            		(10.23e6)          	/* P chipping rate */
-#define CACR           		(1.023e6)		/* CA chipping rate */
-
-#define DEBUG          	 	1
-
-#define SYS_GPS_OFFSET  	315964800            	/* used for METS */
-
-#define CORH_MAX_TIME_DIFF	30	/* max time diff in seconds between local corrections */
-#define CORH_NUM                10	/* number of previous values used to compute RRC */
-#define RRC_ORDER		3
-
-
-
-
-#endif
Index: /trunk/BNC/RTIGS/rtigs.cpp
===================================================================
--- /trunk/BNC/RTIGS/rtigs.cpp	(revision 292)
+++ /trunk/BNC/RTIGS/rtigs.cpp	(revision 293)
@@ -1,103 +1,187 @@
+/* rtigs.cpp
+ * - Source functions
+ *
+ * Copyright (c) 2006
+ * Geoscience Australia
+ *
+ * Written by James Stewart
+ * E-mail: James.Stewart@ga.gov.au
+ *
+ * Enquiries contact
+ * Michael Moore
+ * E-mail: Michael.Moore@ga.gov.au
+ *
+ * Based on the GNU General Public License published Icecast 1.3.12
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
 
-/* -------------------------------------------------------------------------
- * BKG NTRIP Client
- * -------------------------------------------------------------------------
- *
- * Class:      rtigs
- *
- * Purpose:    RTIGS Decoder
- *
- * Author:     L. Mervart
- *
- * Created:    24-Aug-2006
- *
- * Changes:    
- *
- * -----------------------------------------------------------------------*/
+#include <string.h>
+#include "rtigs.h"
 
-#include "rtigs.h"
-#include "bncconst.h"
-
-using namespace std;
-
-#undef L1
-#undef L2
-
-// Constructor
-////////////////////////////////////////////////////////////////////////////
-rtigs::rtigs() {
+void bytes_to_rtigsh(RTIGSH *rtigsh, unsigned char *packet) {
+  memcpy(rtigsh, packet, sizeof(RTIGSH));
+  revbytes((unsigned char *)&(rtigsh->rec_id), 2);
+  revbytes((unsigned char *)&(rtigsh->sta_id), 2);
+  revbytes((unsigned char *)&(rtigsh->GPSTime), 4);
+  revbytes((unsigned char *)&(rtigsh->num_bytes), 2);
 }
 
-// Destructor
-////////////////////////////////////////////////////////////////////////////
-rtigs::~rtigs() {
+int rtigso_to_raw(RTIGSO *rtigso, GPSEpoch *gpse) {
+  struct JPL_COMP_OBS_T soc;
+  int ptr = 0;
+  unsigned char * p1;
+  unsigned char * p2;
+
+  double CA_Range = 0.00;
+  double P1_Range, P2_Range, L1_Cycles, L2_Cycles;
+  double L1_Diff = 0.00;
+  double L2_Diff = 0.00;
+
+  long long ABS_CA_Range = 0;
+
+  double L1_Phase = 0.00;
+  double L2_Phase = 0.00;
+
+  int ABS_L1_Diff = 0;
+  int ABS_L2_Diff = 0;
+  int ABS_L1_Phase = 0;
+  int ABS_L2_Phase = 0;
+
+  gpse->num_sv    = rtigso->num_obs;
+  gpse->GPSTime   = rtigso->GPSTime;
+  gpse->sta_id    = rtigso->sta_id;
+
+  for(ptr = 0; ptr < rtigso->num_obs; ptr++) {
+    memset(&soc, 0, sizeof(struct JPL_COMP_OBS_T));
+    memcpy(&(soc.prn), &(rtigso->data[ptr][0]), 1);
+    memcpy(&(soc.epoch_sequence), &(rtigso->data[ptr][1]), 2);
+    memcpy(&(soc.ca_range[0]), &(rtigso->data[ptr][3]), 18);
+
+    p1 = ((unsigned char *)&ABS_CA_Range);
+    p2 = &(soc.ca_range[0]);
+
+    p1[4] = (p2[0] & 0xF);
+    p1[3] = p2[1];
+    p1[2] = p2[2];
+    p1[1] = p2[3];
+    p1[0] = p2[4];
+
+    p1 = (unsigned char *)&ABS_L1_Diff;
+    p2 = (unsigned char *)&(soc.L1_range_phase[0]);
+
+    if(p2[0] & 0x80)
+      L1_Diff = -1.000;
+    else
+      L1_Diff = 1.000;
+
+    p1[2] = (p2[0] & 0x40) >> 6;
+    p1[1] = ((p2[0] & 0x3F) << 2) + ((p2[1] & 0xC0) >> 6);
+    p1[0] = ((p2[1] & 0x3F) << 2) + ((p2[2] & 0xC0) >> 6);
+
+    if(p2[2] & 0x20)
+      L1_Phase = -1.000;
+    else
+      L1_Phase =  1.000;
+
+    p1 = (unsigned char *)&ABS_L1_Phase;
+    p1[2] = (p2[2] & 0x1F);
+    p1[1] = p2[3];
+    p1[0] = p2[4];
+
+
+
+    p1 = (unsigned char *)&ABS_L2_Diff;
+    p2 = (unsigned char *)&(soc.L2_range_phase[0]);
+
+    if(p2[0] & 0x80)
+      L2_Diff = -1.000;
+    else
+      L2_Diff = 1.000;
+
+    p1[2] = (p2[0] & 0x40) >> 6;
+    p1[1] = ((p2[0] & 0x3F) << 2) + ((p2[1] & 0xC0) >> 6);
+    p1[0] = ((p2[1] & 0x3F) << 2) + ((p2[2] & 0xC0) >> 6);
+
+    if(p2[2] & 0x20)
+      L2_Phase = -1.000;
+    else
+      L2_Phase =  1.000;
+
+    p1 = (unsigned char *)&ABS_L2_Phase;
+    p1[2] = (p2[2] & 0x1F);
+    p1[1] = p2[3];
+    p1[0] = p2[4];
+
+    p2 = &(soc.ca_range[0]);
+    if(p2[0] & 0x20)
+      ABS_L2_Phase += (1 << 22);
+    if(p2[0] & 0x10)
+      ABS_L1_Phase += (1 << 22);
+
+    L1_Phase = L1_Phase * (((double)ABS_L1_Phase) / 50000.00);
+    L2_Phase = L2_Phase * (((double)ABS_L2_Phase) / 50000.00);
+
+    L1_Diff = L1_Diff * (((double)ABS_L1_Diff) / 1000.00);
+    L2_Diff = L2_Diff * (((double)ABS_L2_Diff) / 1000.00);
+
+    CA_Range = (double)ABS_CA_Range / 1000;
+    P1_Range = CA_Range + L1_Diff;
+    P2_Range = CA_Range + L2_Diff;
+
+    L1_Cycles = ((CA_Range + L1_Phase) - (SF2 * L2_Diff)) / W1;
+    L2_Cycles = ((CA_Range + L2_Phase) - (SF1 * L2_Diff)) / W2;
+
+    gpse->sv[ptr].prn         = soc.prn;
+    gpse->sv[ptr].locktime  = soc.epoch_sequence;
+    gpse->sv[ptr].CARange   = CA_Range;
+    gpse->sv[ptr].CASnr     = soc.CA_snr;
+
+    gpse->sv[ptr].P1Range   = P1_Range;
+    gpse->sv[ptr].L1Phase   = L1_Cycles;
+    gpse->sv[ptr].L1Snr     = soc.L1_snr;
+
+    gpse->sv[ptr].P2Range   = P2_Range;
+    gpse->sv[ptr].L2Phase   = L2_Cycles;
+    gpse->sv[ptr].L2Snr     = soc.L2_snr;
+  }
+  return 0;
 }
 
-// 
-////////////////////////////////////////////////////////////////////////////
-void rtigs::Decode(char* buffer, int bufLen) {
+int rtigsm_to_raw(RTIGSM *rtigsm, GPSMet *met) {
+  met->GPSTime = rtigsm->GPSTime;
+  met->sta_id = rtigsm->sta_id;
+  met->temperature = rtigsm->temp;
+  met->pressure = rtigsm->press;
+  met->humidity = rtigsm->humid;
+  revbytes((unsigned char *)&met->temperature, 4);
+  revbytes((unsigned char *)&met->pressure, 4);
+  revbytes((unsigned char *)&met->humidity, 4);
+  return 0;
+}
 
-  // Append the incomming data to the internal buffer
-  // ------------------------------------------------
-  _buffer.append( QByteArray(buffer, bufLen) );
+void revbytes(unsigned char *buf, unsigned char size) {
+  unsigned char tmp;
+  unsigned char *ptr1 = buf;
+  unsigned char *ptr2 = buf + (size - 1);
 
-  // Find the beginning of the message
-  // ---------------------------------
-  bool found = false;
-  for (int ii = 0; ii < _buffer.size(); ii++) { 
-    unsigned short xx;
-    memcpy( (void*) &xx, &_buffer.data()[ii], sizeof(xx) );
-    if (_GPSTrans.f_IsLittleEndian) {
-      SwitchBytes( (char*) &xx, sizeof(xx) );
-    }
-    if (xx == 200) {
-      _buffer = _buffer.mid(ii);
-      found = true;
-      break;
-    }
+  while(ptr1 < ptr2) {
+    tmp = *ptr1;
+    *ptr1 = *ptr2;
+    *ptr2 = tmp;
+    ptr1++;
+    ptr2--;
   }
-
-  if (! found) {
-    _buffer.clear();
-    return;
-  }
-
-  unsigned char* p_buf = (unsigned char*) _buffer.data();  
-
-  unsigned short messType = _GPSTrans.GetRTIGSHdrRecType(p_buf);
-  unsigned short numbytes = _GPSTrans.GetRTIGSHdrRecBytes(p_buf);
-
-  // Not enough new data, return
-  // ---------------------------
-  if (_buffer.size() < numbytes) {
-    return;
-  }
-
-  // Decode the epoch
-  // ----------------
-  if (messType == 200) {
-    RTIGSO_T  rtigs_obs;
-    short numObs = _GPSTrans.Decode_RTIGS_Obs(p_buf, numbytes, rtigs_obs);
-
-    for (short ii = 0; ii < numObs; ii++) {
-      Observation* obs = new Observation();
-
-      obs->SVPRN    = _GPSTrans.DecObs.Obs[ii].sat_prn;
-      obs->GPSWeek  = _GPSTrans.DecObs.Obs[ii].GPSTime / (7 * 86400);
-      obs->GPSWeeks = _GPSTrans.DecObs.Obs[ii].GPSTime % (7 * 86400);
-      obs->C1       = _GPSTrans.DecObs.Obs[ii].l1_pseudo_range;
-      obs->P1       = _GPSTrans.DecObs.Obs[ii].p1_pseudo_range;
-      obs->P2       = _GPSTrans.DecObs.Obs[ii].p2_pseudo_range;
-      obs->L1       = _GPSTrans.DecObs.Obs[ii].p1_phase;
-      obs->L2       = _GPSTrans.DecObs.Obs[ii].p2_phase;
-      obs->SNR1     = int(_GPSTrans.DecObs.Obs[ii].l1_sn * 10);
-      obs->SNR2     = int(_GPSTrans.DecObs.Obs[ii].l2_sn * 10);
-
-      _obsList.push_back(obs);
-    }
-  }
-
-  // Unprocessed bytes remain in buffer
-  // ----------------------------------
-  _buffer = _buffer.mid(numbytes);
 }
Index: /trunk/BNC/RTIGS/rtigs.h
===================================================================
--- /trunk/BNC/RTIGS/rtigs.h	(revision 292)
+++ /trunk/BNC/RTIGS/rtigs.h	(revision 293)
@@ -1,20 +1,221 @@
-
-#ifndef RTIGS_H
-#define RTIGS_H
-
-#include <QByteArray>
-
-#include "../RTCM/GPSDecoder.h"
-#include "cgps_transform.h"
-
-class rtigs : public GPSDecoder {
-public:
-  rtigs();
-  ~rtigs();
-  void Decode(char* buffer = 0, int bufLen = 0);
-private:
-  CGPS_Transform _GPSTrans;
-  QByteArray     _buffer;
-} ;
+/* Defines for the RTIGS <--> Raw Converter
+ * - Source functions
+ *
+ * Copyright (c) 2006
+ * Geoscience Australia
+ *
+ * Written by James Stewart
+ * E-mail: James.Stewart@ga.gov.au
+ *
+ * Enquiries contact
+ * Michael Moore
+ * E-mail: Michael.Moore@ga.gov.au
+ *
+ * Based on the GNU General Public License published Icecast 1.3.12
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+#ifndef __RTIGS_H_INCLUDED__
+#define __RTIGS_H_INCLUDED__ 1
+
+typedef unsigned int    u_int32_t;
+typedef unsigned short  u_int16_t;
+typedef unsigned char   u_int8_t;
+typedef unsigned char   u_char;
+
+#define  C                      ((double)299792458.00)          /* speed of light in vaccuum  */
+#define  F1                     ((double)1575.42E+06)           /* GPS L1 frequency        */
+#define  F2                     ((double)1227.60E+06)           /* GPS L2 frequency        */
+#define  F1_SQUARE      (F1 * F1)               /* GPS L1 frequency squared   */
+#define  F2_SQUARE      (F2 * F2)               /* GPS L2 frequency squared   */
+#define  W1                     ((double)(C / F1))              /* GPS L1 wavelength          */
+#define  W2                     ((double)(C / F2))              /* GPS L2 wavelength          */
+#define  F1ION          (F2_SQUARE / (F1_SQUARE - F2_SQUARE)) /* L1 iono scale factor */
+#define  F2ION          (F1_SQUARE / (F1_SQUARE - F2_SQUARE)) /* L2 iono scale factor */
+#define  SF1            (F1ION + F2ION)
+#define  SF2            (F1ION * 2)
+#define  SF3            (F2ION * 2)
+#define  MAXCYCLEOSL1 374               // changed to fit 83.88 metres 441 Feb. 24/2004 ~100m in cycles was 526
+#define  MAXCYCLEOSL2 291               // changed to fit 83.88 metres 343 Feb. 24/2004 was ~100m in cycles 410
+
+/* RTIGSH_T Structure -> RTIGS Header structure, Used For Working Out What Sort Of Packet We Got */
+struct RTIGSH_T
+        {
+        u_int16_t       rec_id;
+        u_int16_t       sta_id;
+        u_int32_t       GPSTime;
+        u_int16_t       num_bytes;
+        u_int8_t        IODS;
+        u_int8_t        misc;
+        };
+
+
+/* RTIGSS_T Structure -> RTIGS Station structure, normally rec_id = 100 */
+struct RTIGSS_T
+        {
+        u_int16_t       rec_id;
+        u_int16_t       sta_id;
+        u_int32_t       GPSTime;
+        u_int16_t       num_bytes;
+        u_int8_t        IODS;
+        u_int8_t        sta_rec_type;
+        u_char          IGS_UniqueID[8];
+        };
+
+
+/* RTIGSO_T Structure -> RTIGS Observation structure, normally rec_id = 200 */
+struct RTIGSO_T
+        {
+        u_int16_t       rec_id;
+        u_int16_t       sta_id;
+        u_int32_t       GPSTime;
+        u_int16_t       num_bytes;
+        u_int8_t        IODS;
+        u_int8_t        num_obs;
+        u_char          data[12][21];
+        };
+
+/* RTIGSE_T Structure -> RTIGS Ephemeris structure, normally rec_id = 300 */
+struct RTIGSE_T
+        {
+        u_int16_t       rec_id;
+        u_int16_t       sta_id;
+        u_int32_t       GPSTime;
+        u_int16_t       num_bytes;
+        u_int8_t        IODS;
+        u_int8_t        prn;
+        u_char          data[72];
+        };
+
+
+/* RTIGSM_T Structure -> RTIGS Met structure, normally rec_id = 400 */
+struct RTIGSM_T
+        {
+        u_int16_t       rec_id;
+        u_int16_t       sta_id;
+        u_int32_t       GPSTime;
+        u_int16_t       num_bytes;
+        u_int8_t        IODS;
+        u_int8_t        num_obs;
+        long            temp;
+        long            press;
+        long            humid;
+        };
+
+/* The 21 Byte SOC Compressed Observation Structure per SV */
+struct JPL_COMP_OBS_T
+        {
+        unsigned char prn;                      // satellite ID
+        unsigned short epoch_sequence;  // like Ashtech seq number of phase epochs
+                                                                        // was like this, now modulo 10 hours,
+                                                                        // each digit is now 1 sec, not .05 secs like before
+        unsigned char ca_range[5];                      // ca range in millimeters
+                                                                // first 4 bits are status bits, as follows
+                                                                // if bit 7 on, sucessful packing of ca_range
+                                                                // if bit 6 on, Z track mode or AS is on
+                                                                // if bit 5 on, overflow of L2_block phase
+                                                                // if bit 4 on, overflow of L1_block phase
+                                                                // next 36 bits are the observable
+                                                                // 68719.476735 is the max allowable obsev.
+                                                                // if not packed, L2_block and L1_block is
+                                                                // just then packed with 0s
+
+        unsigned char CA_snr;           // receiver snr for ca  in dbHz KML the SNR is (DBHz * 4.25) rounded to an int  (max is 60.0)
+        unsigned char L2_range_phase[5];
+                                                                // first 2 bytes and 2 bits is for the range, next 6 bits and 2 bytes are for phase.
+                                                                //
+                                                                // range units are in millimeters, from -131071 to 131071   (2^17 - 1)
+                                                                // 0000 0000 0000 0000 01 would be +1 mm
+                                                                // 100000000000000001 would be -1 mm
+                                                                // 0100 0000 0000 0000 00 would be  65536 mm
+                                                                // 1100 0000 0000 0000 00 would be -65536 mm
+                                                                // 0111 1111 1111 1111 11 would be  131071 mm
+                                                                // 111111111111111111 woule be -131071 mm
+                                                                // dynamic range must be <= 131.071 meters
+                                                                //
+                                                                // phase units are in 2/100 millimeters from -4194304 to 4194304
+                                                                // 00 0000 0000 0000 0000 0001  would be +.02 mm
+                                                                // 10 0000 0000 0000 0000 0001  would be -.02 mm
+                                                                // 01 1111 1111 1111 1111 1111  ( 2097151) would be  41943.02 mm
+                                                                // 11 1111 1111 1111 1111 1111  (-2097151) would be -41943.02 mm
+                                                                //                              (2^21 - 1)*2 mm
+                                                                // dynamic range must be <= 41.94302 meters
+                                                                //
+                                                                // note if the limits are exceded, a -0 (minus zero) is returned
+                                                                // indicating not a number
+                                                                //
+                                                                // Note however, we extended this dynamic range to 83.88606 meters as
+                                                                // below with the spare bits in the ca_range field. If this limit
+                                                                // is exceeded we return a -0 ( minus zero )
+        unsigned char L2_snr;           // snr for this data type  in dbHz, the SNR is (DBHz * 4.25) rounded to an int (max is 60.0 )
+        unsigned char L1_range_phase[5];                // same as format for L2_range_phase
+        unsigned char L1_snr;           // snr for this data type  in dbHz, the SNR is (DBHz * 4.25) rounded to an int (max is 60.0 )
+        };
+
+
+/* GPSSatellite Structure -> 44 Byte raw SV Structure */
+struct GPSSatellite
+        {
+        unsigned char prn;
+        unsigned char CASnr;
+        unsigned char L1Snr;
+        unsigned char L2Snr;
+        double  CARange;
+        double  P1Range;
+        double  L1Phase;
+        double  P2Range;
+        double  L2Phase;
+        unsigned short locktime;
+        };
+
+/* GPSEpoch Structure -> raw epoch Structure */
+struct GPSEpoch_T
+        {
+        unsigned int    GPSTime;
+        unsigned short  sta_id;
+        unsigned char   num_sv;
+        unsigned char   padding;
+        struct GPSSatellite sv[12];
+        };
+
+struct GPSMet_T
+        {
+        unsigned int GPSTime;
+        unsigned short sta_id;
+        long temperature;
+        long humidity;
+        long pressure;
+        };
+
+typedef struct RTIGSO_T RTIGSO;
+typedef struct RTIGSE_T RTIGSE;
+typedef struct RTIGSS_T RTIGSS;
+typedef struct RTIGSM_T RTIGSM;
+typedef struct RTIGSH_T RTIGSH;
+typedef struct GPSEpoch_T GPSEpoch;
+typedef struct GPSMet_T GPSMet;
+
+
+/* Function Declarations */
+extern void bytes_to_rtigsh(RTIGSH *rtigsh, unsigned char *packet);
+extern int rtigso_to_raw(RTIGSO *rtigso, GPSEpoch *gpse);
+extern int rtigsm_to_raw(RTIGSM *rtigsm, GPSMet *met);
+
+
+void revbytes(unsigned char *buf, unsigned char size);
 
 #endif
+
+
Index: unk/BNC/RTIGS/rtigs_records.h
===================================================================
--- /trunk/BNC/RTIGS/rtigs_records.h	(revision 292)
+++ 	(revision )
@@ -1,251 +1,0 @@
-/***************************************************************************
-                          rtigs_records.h  -  description
-                             -------------------
-    begin                : Wed Aug 27 2003
-    copyright            : (C) 2003 by Ken MacLeod
-    email                : ken.macleod@nrcan.gc.ca.
- ***************************************************************************/
-
-/***************************************************************************
- *
- *   This program is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version. 
- *
- ***************************************************************************/
-#ifndef _RTIGS_T
-#define _RTIGS_T
-
-/*****************************************************************************
-* RT-IGS record structures
-*
-*	General:
-*
-*		Every record will have a defined number. We propose the following:
-*				1) Station record number 100;
-*				2) Observation record number 200;
-*				3) Ephemeris record number 300;
-*				4) Meteorological record number 400;
-*
-*		Every station will have a unique number. We propose the following:
-*
-*				1-99 reserved for JPL
-*				100-199 reserved for NRCan
-*				200-299 reserved for NGS
-*				300-399 reserved for ESOC
-*				400-499 reserved for GFZ
-*				500-599 reserved for BKG
-*				600-699 reserved for GEOSCIENCE AUS.
-*				700-799 others
-*				etc
-*		The number of bytes in each real time message will include the header as
-*		well as the data content, but NOT the pointer. For example :
-*
-*			1) A station message is output once per hour and is 20 bytes
-*
-*			2) An observation message is output once per second. The header is
-*				12 bytes long and the SOC data is 21 bytes per PRN. So a typical
-*				RTIGSO_T message will be 390 bytes if 8 sats are being tracked
-*
-*			3) An ephemeris message is output when the ephemeris is decoded by the
-*				GPS receiver. The time in the Ephemeris header is the collected time.
-*				One ephemeris can be bundled in a RTIGSE_T.
-*				A RTIGSE_T  message contains one eph.  the  message consists of 12 header
-*				bytes and 72 ephemeris bytes, for a total of 84 bytes.
-*
-*			4) The RTIGSM_T  (met) message should be issues once every 15 minutes.
-*				 A basic met message consists of a 12 byte header and 3 longs (temp,
-*				 press and relative humidity) for a total of 24 bytes.
-*				
-*		All records will be related to a station configuration indicated by the
-*		Issue of Data Station(IODS). The IODS will enable the user to identify
-*		the equipment and software that was used to derive the observation data.
-*
-*		Each record header will contain the GPS Time in seconds which is
-*		continuous from ((6 Jan-1980)).
-*
-*		The data payload of each record will consist of observations. The
-*		structures shown below indicate a pointer to data but in fact the broadcast
-*		messages will not contain the pointed only the data. Users will have to
-*		manage the data and the pointer is shown to illustrate where the data is
-*		located in the message and one possible data management option.
-*		
-*
-* 		All record data in network byte order (Big Endian), ie  IA32 users will
-*		have to swap bytes ;-)
-******************************************************************************
-* Developed by Ken MacLeod Aug. 27/2003
-* Updated and revised Feb. 10/2004 with comments from R. Muellershoen
-*****************************************************************************/
-
-#define MAXSTA	256
-#define MAXSOC 264		/* 12 + (12 * 21) = 264*/
-#define MAXEPH 876			/* 12 + (12 * 72) = 876*/
-#define MAXMETS 6
-
-
-/*****************************************************************************
-* Structure name : RTIGSS_T
-*
-*		Purpose:
-* 		
-*		Encapsulate the station information that is required for real-time users
-*
-*		Users should use this record is to  link data to a specific station
-*		configuration.
-*		The station message should be transmitted by station operator every
-*		hour and upon update.
-*		 If the stations record Issue of Data Station(IODS) and the IODS in the
-*		observation record do not match then the data should be used without
-*		further investigation
-*
-*		
-*
-* 		This record is not intended to replace the IGS Station log but it is
-*		seen as a subset of the IGS log and contains information that enables
-*		real-time users to monitor station changes.
-*
-* 
-*Version: 1.0
-*
-*By Ken MacLeod Aug. 27/2003
-*Changes: Revised Feb. 10/2004 updated the message description info.
- ****************************************************************************/
-
-typedef struct rtigs_station
-{
-	unsigned short rec_id; 					/*100 indicates station record this message */
-																/* to be issued once per hour*/
-	unsigned short sta_id;					/*unique number assigned to each station. */
-																/* Uniquely linked to an IGS Station log by */
-																/* the station record*/
-	unsigned long GPSTime;				/* time of issue, GPS time is seconds from */
-																/* the beginning of GPS (6 Jan-1980)*/
-	unsigned short num_bytes;			/* total number of bytes in the message,  */
-																/* including the header*/
-	unsigned char IODS;						/* a flag indicating the current station */
-																/* configuration this will change every time */
-																/* the station hardware changes*/														
-	unsigned char sta_rec_type;			/* could be various station data formats: */
-																/*  0 indicates that there is no additional */
-																/*  station data*/
-	char IGS_UniqueID[8];					/* IGS ID eg NRC1 will use IGS 4 character */
-																/* standard but c requires a \0 to terminate */
-																/* the string */
-	unsigned char *data;						/* default station headers Does Not  */
-																/* contain data.  The current message does */
-																/* not contain additional station  */
-																/* information the pointer is shown only */
-																/* to illustrate  options*/
-}RTIGSS_T;
-
-/******************************************************************************
- * Structure name : RTIGSO_T
- *
- * Purpose :  GPS Observations
- *						Currently the JPL Soc format is used to compress the
- *						observation data. 
- *						See JPL's website for a description of the SOC
- * 						compression routine
- *Version: 1.0
- *
- *By Ken MacLeod Aug. 27/2003
- *Changes: Revised Feb. 10/2004 Remove station clock and obs time
- * in milliseconds and add to the message description
- *****************************************************************************/
-typedef struct rtigs_obs
-{
-	unsigned short rec_id;					/* 200 indicates rt-igs gps observation*/
-	unsigned short sta_id;					/* Unique num. assigned to each station */
-																/* Uniquely linked to an IGS Station log y */
-																/* the station record*/
-	unsigned long GPSTime;				/* observation time of issue, GPS time is */
-																/* seconds from the beginning of GPS */
-																/* (6 Jan-1980)*/
-	unsigned short num_bytes;			/* total number of bytes in the message,  */
-																/* including the header, but not the data */
-																/* pointer*/
-	unsigned char IODS;						/* a flag indicating the current station */
-																/* configuration that derived  the */
-																/* observations this  value will change */
-																/* every time the station configuration */
-																/* changes*/
-	unsigned char num_obs;				/* number of GPS Observations in data block*/
-	unsigned char *data;						/* pointer to soc observation data (4 byte pointer), this pointer */
-																/* is not in the message the data starts */
-																/* here,  the pointer is used to manage the */
-																/* SOC data once the RTIGS0_T message has */
-																/* been decoded */
-} RTIGSO_T;
-/*****************************************************************************
- * Structure name : RTIGSE_T
- *
- * Purpose :  SV Ephemeris in Broadcast format parity removed
- *
- *Version: 1.0
- *
- *By Ken MacLeod Aug. 27/2003
- *Changes: Revised Feb. 10/2004
- *****************************************************************************/
-typedef struct rtigs_ephemeris
-{
-	unsigned short	rec_id;						/* 300 indicates rt-igs eph*/
-	unsigned short	sta_id;						/* unique number assigned */
-																	/* to each station*/
-	unsigned long CollectedGPSTime;					/* time ephemeris received at */
-																	/*station, GPS time is seconds */
-																	/* from the beginning of GPS */
-																	/* (6 Jan-1980)*/
-	unsigned short	num_bytes;				/* total number of bytes in the message, */
-																	/* including the header, but not the size */
-																	/*  of the data pointer*/
-	unsigned char	IODS;							/* a flag indicating the current station */
-																	/* configuration that derived the */
-																	/* observations this will change every */
-																	/* time the sta config changes*/
-	unsigned char prn;								/* PRN*/
-	unsigned char *data;							/* In the RTIGSE_T message the data */
-																	/* starts here,  the pointer is used to */
-																	/* manage the eph data once the RTIGSE_T */
-																	/* message has  been decoded */
-																	/* The RTIGSE_T eph. format consists of */
-																	/* the 3 broadcast sub frames  with the */
-																	/* parity bits removed so 3 */
-																	/* subframes = 72 bytes */
-} RTIGSE_T;
-
-/***********************************************************************
- * Structure name : RTIGSM_T
- *
- * Purpose :  Station Meteorological observations
- *
- *Version: 1.0
- *
- *By Ken MacLeod Aug. 27/2003
- *Changes: Changed the met array to an long pointer
- ***********************************************************************/
-typedef struct rtigs_mets
-{
-	unsigned short		rec_id; 					/* 400 indicates rt-igs met*/
-	unsigned short		sta_id; 					/* unique number assigned to each */
-																	/* station*/
-	unsigned long		GPSTime;				/* time of issue, GPS time is seconds */
-																	/* from the beginning of GPS (6 Jan-1980)*/
-	unsigned short		num_bytes; 			/* total number of bytes in the message,*/
-																	/* including the header but not the pointer*/
-	unsigned char		IODS;						/* a flag indicating the current station */
-																	/* config that derived the observations */
-																	/* this will change every time the station */
-																	/* configuration changes*/
-	unsigned char		numobs;					/* if only temp, press, rel hum then : 3  */
-	long *mets;											/* temp(Deg C),   press (mb),  */
-																	/* rel humid(%),  zenith Wet(metres), */
-																	/* Zenith Dry(metres),  Zenith Total */
-																	/* (metres) and  each scaled by 1000 so */
-																	/* 1000.123 mb = 1000123*/
-																	/*if the zenith observations are not */
-																	/* present only enter 3 for the num of obs.*/
-} RTIGSM_T;
-
-#endif
Index: unk/BNC/RTIGS/rtstruct.h
===================================================================
--- /trunk/BNC/RTIGS/rtstruct.h	(revision 292)
+++ 	(revision )
@@ -1,233 +1,0 @@
-/***************************************************************************
-                          rtstruct.h  -  description
-                             -------------------
-    begin                : Tue Mar 7 2000
-    copyright            : (C) 2000 by Ken MacLeod
-    email                : macleod@geod.nrcan.gc.ca
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- ***************************************************************************/
-/*-------------------------------------------------------------------------*/
-/* Name : rtstruct.h								   */
-
-/* Purpose : structure definitions for the wide area prototype		   */
-
-/* RCS: $Header: rtstruct.h,v 3.10 99/08/18 15:06:33 macleod Released $ */
-
-/* Externals :                                                             */
-/*-------------------------------------------------------------------------*/
-#ifndef _RTSTRUCT
-#define _RTSTRUCT
-
-/**************************************************************************/
-/***									***/
-/***	RTAP Function Prototypes:					***/
-/***									***/
-/***		1) typedef defines the RTAP types for non-RTAP		***/
-/***		   compiles						***/
-/***									***/
-/***		2) To compile within RTAP use -D_RTAP compile option	***/
-/***									***/
-/***    Note: Most function prototypes are commented out until the	***/
-/***	      corresponding functions are changed accordingly		***/
-/***									***/
-/**************************************************************************/
-
-#ifdef _RTAP
-
-#include <rtap/types.h>
-#include <rtap/database.h>
-
-#else
-
-typedef double          rtDouble;
-typedef float           rtFloat;
-typedef char            rtChar;
-typedef unsigned char   rtUInt8;
-typedef unsigned short  rtUInt16;
-typedef unsigned int    rtUInt32;
-typedef int             rtInt32;
-typedef short           rtInt16;
-typedef char            rtInt8;
-typedef int             rtInt;
-typedef struct timeval	rtTime;
-
-typedef rtUInt32        rtDbQuality;
-typedef rtUInt8         rtLogical;
-typedef rtUInt8         rtBytes4[4];
-typedef rtUInt8         rtBytes8[8];
-typedef rtUInt8         rtBytes12[12];
-typedef rtUInt8         rtBytes16[16];
-typedef rtUInt8         rtBytes20[20];
-typedef rtUInt8         rtBytes32[32];
-typedef rtUInt8         rtBytes48[48];
-typedef rtUInt8         rtBytes64[64];
-typedef rtUInt8         rtBytes80[80];
-typedef rtUInt8         rtBytes128[128];
-typedef rtUInt8         rtBytes256[256];
-
-#endif
-
-/* Now define our constants */
-/* Our CONS_T structure member names are now lower case to prevent conflict */
-
-#define  MAX_STA     	     (24)		/* maximum stations  	   */
-#define  PI   (3.141592653589793)		/* value of PI		   */
-#define  DTR  (0.017453292519943)		/* deg to rad conversion con. */
-#define  C	   (299792458.00)		/* speed of light in vaccuum  */
-#define  F1	    (1575.42E+06)		/* GPS L1 frequency	   */
-#define  F1_SQUARE	(F1 * F1)		/* GPS L1 frequency squared   */
-#define  L1              (C / F1)		/* GPS L1 wavelength          */
-#define  F2	    (1227.60E+06)		/* GPS L2 frequency	   */
-#define  F2_SQUARE	(F2 * F2)		/* GPS L2 frequency squared   */
-#define  L2              (C / F2)		/* GPS L2 wavelength          */
-#define  F3             (F1 - F2)		/* GPS widelane frequency     */
-#define  L3              (C / F3)		/* GPS widelane wavelength    */
-#define  F1ION (F2_SQUARE / (F1_SQUARE - F2_SQUARE)) /* L1 iono scale factor */
-#define  F2ION (F1_SQUARE / (F1_SQUARE - F2_SQUARE)) /* L2 iono scale factor */
-#define  IonoH	       (350000.0)		/* Ionospheric height in metres */
-
-				/*******************************
-				* Content: Broadcast Orbit
-				*          Representation
-				********************************/
-typedef struct broadcast{
-double	satellite;						/* satellite number 	*/
-double	gps_week;					/* gps week number from 81/01/06*/
-double 	user_range_acc;		/* user range accuracy in meters  */
-double	sat_health;				/* satellite health (all bits)   */
-double	fit_interval;				/* ephemeris fit interval   */
-double	l2code;						/* Codes on L2 indicator  */
-double	l2pflag;						/* Data flag for L2 P code */
-double	issue_of_clock;		/* issue of clock 	  */
-double	issue_of_eph;			/* issue of ephemeris 		   */
-double	transmit_time;			/* time of transmission	   */
-double	clock_ref_time;			/* reference time of the clock	   */
-double	eph_ref_time;			/* reference time of the ephem   */
-double	a0;								/* satellite clock coefficient	   */
-double	a1;								/* satellite clock coefficient	   */
-double	a2;								/* satellite clock coefficient	   */
-double 	ref_mean_anmly;		/* mean anomoly at reference time */
-double	mean_mot_diff;			/* mean motion difference   */
-double	orbit_ecc;					/* orbit eccentricity		   */
-double	orbit_semimaj;			/* square root of orbit semimajor axis */
-double	arg_of_perigee;		/* argument of perigee	   */
-double	orbit_incl;					/* orbit inclination		   */
-double	incl_rate;					/* orbit inclination rate   */
-double	right_asc;					/* right ascension	   */
-double	right_asc_rate;			/* rate of right ascension   */
-double	lat_cos_corr;			/* ampl of cos harm corr to arg of lat */
-double	lat_sin_corr;				/* ampl of sin harm corr to arg of lat */
-double	orbit_cos_corr;			/* ampl of cos harm corr to orbit	   */
-double	orbit_sin_corr;			/* ampl of sin harm corr to orbit	   */
-double	incl_cos_corr;			/* ampl of cos harm corr to the incl   */
-double	incl_sin_corr;			/* ampl of sin harm corr to the incl   */
-double	group_delay;			/* estimated group delay differential  */
-}BEPH_T;
-
-
-
-					/******************************
-					* Content:Receiver independent 
-					* GPS observation data structure
-					* contains all possible obs
-					*******************************/
-typedef struct complete_measurement{
-unsigned long		GPSTime;			/* broadcast time sec.*/
-unsigned char	  chn;							/* Channel*/
-unsigned char   sat_prn;				/* satellite ID*/
-unsigned short	ntrvl;			/* number of seconds */
-unsigned char		flag[4];								/*observation quality flags*/
-float				l1_sn;				/* signal-to-noise CA frequency 1 */
-
-double		l1_pseudo_range;	/* frequency-1 CA pseudorange */
-double		l1_phase;		/* frequency-1 CA carrier phase   */
-											/*KML for this struct SNR will be DBHz */
-double		p1_pseudo_range;	/* frequency-1 P1 pseudorange */
-double		p1_phase;		/* frequency-1 P1 carrier phase   */
-float				p1_sn;			/* signal-to-noise P1 frequency 1 */
-float 			l2_sn;			/* signal-to-noise frequency 2 */
-
-                      /*KML for this struct SNR will be DBHz */
-double		l2_pseudo_range;	/* frequency-2 pseudorange (XCorr) */
-double		l2_phase;		/* frequency-2 carrier phase (XCorr)  */
-										/*KML for this struct SNR will be DBHz */
-double		p2_pseudo_range;	/* frequency-2 pseudorange     */
-double		p2_phase;		/* frequency-2 carrier phase   */
-}CMEAS_T;
-
-
-
-
-					/*******************************
-					* Content:Turbo Rogue Receiver 
-					* Raw Turbo Broadcast Message
-					*******************************/ 
-typedef struct rawtbeph{
-char		block_type;		/* Turbo record type */
-char		block_length;		/* Turbo record in bytes */
-char		Satellite;                      /* Sat. PRN */
-char		Dummy;
-long		GPSEpochTime;
-long		GPSCollectedTime;
-unsigned long	SubFrame1[6];      /* SubFrame1 hexbits */
-unsigned long	SubFrame2[6];      /* SubFrame2 hexbits */
-unsigned long	SubFrame3[6];		 /* SubFrame3 hexbits */
-}RNAV_T;
-
-					/********************************
-					* Content: Turbo Rogue Receiver 
-					* Raw TurboRogue GPS observation 
-					********************************/
-typedef struct rawtbobserv{
-char		BlockType; 
-char		BlockSize;
-char		Satellite;
-char		Channel;
-long		GPSTimeTag;
-char		SampleInterval;
-char		Flags;
-unsigned short	SNR[3];
-double		CAfaz;
-double		CAtau;
-float		faz1;
-float		tau1;
-float		faz2;
-float		tau2;
-}TBIN_T;
-
-				/*******************************
-				* Content:Turbo Rogue Receiver
-				* Turbo Broadcast Message 
-				*******************************/
-typedef struct reducedbeph{
-long		Satellite;
-long		GPSCollectedTime;
-unsigned long	SubFrame1[6];      /* SubFrame1 hexbits */
-unsigned long	SubFrame2[6];      /* SubFrame2 hexbits */
-unsigned long	SubFrame3[6];		 /* SubFrame3 hexbits */
-}TNAV_T;
-
-
-					/*************************************
-					* Content: Meteorological Observations
-					* Summarized  met data
-					*************************************/
-typedef struct scaledmet{
-long		GPSTime;					/*GPS Time */
-long		Temp;							/*scaled temperature */
-long		TempStdDev;			  /*scaled temp. std dev */
-long		Pressure;					/*scaled pressure */
-long		PressureStdDev	;	/*scaled press. std dev */
-long		RelHum;					  /*scaled percentage */
-long		RelHumStdDev;		  /*scaled prec. std dev */
-}METS_T;
-
-#endif
Index: /trunk/BNC/bnc.pro
===================================================================
--- /trunk/BNC/bnc.pro	(revision 292)
+++ /trunk/BNC/bnc.pro	(revision 293)
@@ -16,7 +16,5 @@
           RTCM/GPSDecoder.h RTCM/RTCM2.h RTCM/RTCM2Decoder.h          \
           RTCM3/rtcm3.h RTCM3/rtcm3torinex.h                          \
-          RTIGS/rtigs.h RTIGS/cgps_transform.h RTIGS/rtacp.h          \
-          RTIGS/rtigs_records.h  RTIGS/rtstruct.h
-
+          RTIGS/rtigs.h RTIGS/RTIGSDecoder.h
 
 SOURCES = bncmain.cpp bncgetthread.cpp  bncwindow.cpp bnctabledlg.cpp \
@@ -25,5 +23,5 @@
           RTCM/RTCM2.cpp RTCM/RTCM2Decoder.cpp                        \
           RTCM3/rtcm3.cpp RTCM3/rtcm3torinex.cpp                      \
-          RTIGS/rtigs.cpp RTIGS/cgps_transform.cpp
+          RTIGS/rtigs.cpp RTIGS/RTIGSDecoder.cpp
 
 RC_FILE = bnc.rc
Index: /trunk/BNC/bncgetthread.cpp
===================================================================
--- /trunk/BNC/bncgetthread.cpp	(revision 292)
+++ /trunk/BNC/bncgetthread.cpp	(revision 293)
@@ -52,5 +52,5 @@
 #include "RTCM/RTCM2Decoder.h"
 #include "RTCM3/rtcm3.h"
-#include "RTIGS/rtigs.h"
+#include "RTIGS/RTIGSDecoder.h"
 
 using namespace std;
@@ -241,5 +241,5 @@
     else if (_format.indexOf("RTIGS") != -1) {
       emit(newMessage("Get Data: " + _staID + " in RTIGS format"));
-      _decoder = new rtigs();
+      _decoder = new RTIGSDecoder();
     }
     else {
