Exemple #1
0
bool MDA::Parse( const SENTENCE& sentence )
{
//   ASSERT_VALID( this );

/*Wind speed, meters/second
**Wind speed, knots
**Wind direction,
**degrees Magnetic
**Wind direction, degrees True
**$
**--
**MDA,x.x,I,x.x,B,x.x,C,x.x,C,x.x,x.x,x.x,C,x.x,T,x.x,M,x.x,N,x.x,M*hh<CR><LF>
**    |   |  |  |          Dew point, degrees C
**    |   |  |  |          Absolute humidity, percent
**    |   |  |  |          Relative humidity, percent
**    |   |  |  |        Water temperature, degrees C
**    |   |  |  |          Air temperature, degrees C
**    |   |  |----Barometric pressure, bars
**    |----- Barometric pressure, inches of mercur
*/


   /*
   ** First we check the checksum...
   */

   if ( sentence.IsChecksumBad( sentence.GetNumberOfDataFields() ) == TRUE || FALSE ) //diferent vendors have different length of data message and not 24 field as in standard.
   {
      SetErrorMessage( _T("Invalid Checksum") );
      return( FALSE );
   }

Pressure       = sentence.Double( 3 );
UnitOfMeasurement = sentence.Field( 4 );

if(UnitOfMeasurement==wxT("B"))
{
   Pressure       = sentence.Double( 3 ); //from bar to Hecto pascal

}


   return( TRUE );
}
Exemple #2
0
bool GLL::Parse( const SENTENCE& sentence )
{
//   ASSERT_VALID( this );

   /*
   ** GLL - Geographic Position - Latitude/Longitude
   ** Latitude, N/S, Longitude, E/W, UTC, Status
   **
   **        +-------------------------------- 1) Latitude
   **        |       +------------------------ 2) N or S (North or South)
   **        |       | +---------------------- 3) Longitude
   **        |       | |        +------------- 4) E or W (East or West)
   **        |       | |        | +----------- 5) Universal Time Coordinated (UTC)
   **        |       | |        | |         +- 6) Status A - Data Valid, V - Data Invalid
   **        |       | |        | |         | +7) Checksum
   ** $--GLL,llll.ll,a,yyyyy.yy,a,hhmmss.ss,A*hh<CR><LF>
   */

   /*
   ** First we check the checksum...
   */

      int target_field_count = 6;

      NMEA0183_BOOLEAN check = sentence.IsChecksumBad( 7 );

      if ( check == NTrue )
      {

  /*
            ** This may be an NMEA Version 2.3 sentence, with "Mode" field
  */
            wxString checksum_in_sentence = sentence.Field( 7 );
            if(checksum_in_sentence.StartsWith(_T("*")))       // Field is a valid erroneous checksum
            {
                  SetErrorMessage( _T("Invalid Checksum") );
                  return( FALSE );
            }

            else
            {
                  target_field_count = 7;
                  check = sentence.IsChecksumBad( 8 );
                  if( check == NTrue)
                  {
                        SetErrorMessage( _T("Invalid Checksum") );
                        return( FALSE );
                  }
            }
      }


      if ( sentence.GetNumberOfDataFields() == target_field_count )
      {
            Position.Parse( 1, 2, 3, 4, sentence );
            UTCTime     = sentence.Field( 5 );
            IsDataValid = sentence.Boolean( 6 );

            return( TRUE );
      }

      //    May be old style GLL sentence
      if ( sentence.GetNumberOfDataFields() == 4 )
      {
            Position.Parse( 1, 2, 3, 4, sentence );
            IsDataValid = NTrue;

            return( TRUE );
      }

      //    A real error...
      SetErrorMessage( _T("Invalid FieldCount") );
      return( FALSE );
}
Exemple #3
0
bool RTE::Parse( const SENTENCE& sentence )
{
   /*
   ** RTE - Routes
   **
   **        1   2   3 4	 5		       x    n
   **        |   |   | |    |           |    |
   ** $--RTE,x.x,x.x,a,c--c,c--c, ..... c--c*hh<CR><LF>
   **
   ** Field Number: 
   **  1) Total number of messages being transmitted
   **  2) Message Number
   **  3) Message mode
   **     c = complete route, all waypoints
   **     w = working route, the waypoint you just left, the waypoint you're heading to then all the rest
   **  4) Waypoint ID
   **  x) More Waypoints
   **  n) Checksum
   */

   Waypoints.clear();

   int field_number = 1;

   m_TotalNumberOfMessages = sentence.Double( 1 );
   
   double this_message_number = sentence.Double( 2 );
   
   if ( this_message_number == 1.0 )
   {
      /*
      ** Make sure we've got a clean list
      */

       Waypoints.clear();
   }

   std::string field_data = sentence.Field( 3 );

   if ( field_data == "c" )
   {
      TypeOfRoute = CompleteRoute;
   }
   else if ( field_data == "w" )
   {
      TypeOfRoute = WorkingRoute;
   }
   else
   {
      TypeOfRoute = RouteUnknown;
   }

   RouteName = sentence.Field( 4 );

   int number_of_data_fields = sentence.GetNumberOfDataFields();
   field_number = 5;

   std::string string_to_add;

   while( field_number < number_of_data_fields )
   {
      Waypoints.push_back(sentence.Field(field_number));
      field_number++;
   }

   return( true );
}
Exemple #4
0
bool RTE::Parse( const SENTENCE& sentence )
{
   /*
   ** RTE - Routes
   **
   **        1   2   3 4	 5		       x    n
   **        |   |   | |    |           |    |
   ** $--RTE,x.x,x.x,a,c--c,c--c, ..... c--c*hh<CR><LF>
   **
   ** Field Number:
   **  1) Total number of messages being transmitted
   **  2) Message Number
   **  3) Message mode
   **     c = complete route, all waypoints
   **     w = working route, the waypoint you just left, the waypoint you're heading to then all the rest
   **  4) Waypoint ID
   **  x) More Waypoints
   **  n) Checksum
   */

   delete_all_entries();

   int field_number = 1;

   total_number_of_messages = sentence.Integer( 1 );
//   total_number_of_messages = sentence.Double( 1 );

   int this_message_number = sentence.Integer( 2 );
//   double this_message_number = sentence.Double( 2 );

   if ( this_message_number == 1 )
   {
      /*
      ** Make sure we've got a clean list
      */

      delete_all_entries();
   }


   if ( sentence.Field( 3 ).StartsWith(_T("c")) )
   {
      TypeOfRoute = CompleteRoute;
   }
   else if ( sentence.Field( 3 ).StartsWith(_T("w")))
   {
      TypeOfRoute = WorkingRoute;
   }
   else
   {
      TypeOfRoute = RouteUnknown;
   }

   RouteName = sentence.Field( 4 );

   int number_of_data_fields = sentence.GetNumberOfDataFields();
   field_number = 5;

   while( field_number < number_of_data_fields )
   {
      Waypoints.Add( ( sentence.Field( field_number ) )) ;
      field_number++;
   }

   return( TRUE );
}
Exemple #5
0
bool VTG::Parse( const SENTENCE& sentence )
{
//   ASSERT_VALID( this );

   /*
   ** VTG - Track made good and Ground speed
   **
   **        1   2 3   4 5	 6 7   8 9
   **        |   | |   | |	 | |   | |
   ** $--VTG,x.x,T,x.x,M,x.x,N,x.x,K*hh<CR><LF>
   **
   ** Field Number:
   **  1) Track Degrees
   **  2) T = True
   **  3) Track Degrees
   **  4) M = Magnetic
   **  5) Speed Knots
   **  6) N = Knots
   **  7) Speed Kilometers Per Hour
   **  8) K = Kilometers Per Hour
   **  9) Checksum
   */

   /*
   ** First we check the checksum...
   */

      int target_field_count = 8;

      NMEA0183_BOOLEAN check = sentence.IsChecksumBad( 9 );

      if ( check == NTrue )
      {

  /*
      ** This may be an NMEA Version 2.3 sentence, with "Mode" field
  */
            wxString checksum_in_sentence = sentence.Field( 9 );
            if(checksum_in_sentence.StartsWith(_T("*")))       // Field is a valid erroneous checksum
            {
                  SetErrorMessage( _T("Invalid Checksum") );
                  return( FALSE );
            }

           else
           {
                  target_field_count = 9;
                  check = sentence.IsChecksumBad( 10 );
                  if( check == NTrue)
                  {
                        SetErrorMessage( _T("Invalid Checksum") );
                        return( FALSE );
                  }
            }
      }



   if ( sentence.GetNumberOfDataFields() != target_field_count )
   {
         SetErrorMessage( _T("Invalid FieldCount") );
         return( FALSE );
   }


   TrackDegreesTrue       = sentence.Double( 1 );
   TrackDegreesMagnetic   = sentence.Double( 3 );
   SpeedKnots             = sentence.Double( 5 );
   SpeedKilometersPerHour = sentence.Double( 7 );

   return( TRUE );
}
Exemple #6
0
bool GSV::Parse( const SENTENCE& sentence )
{
/*
  $GPGSV,2,1,08,01,40,083,46,02,17,308,41,12,07,344,39,14,22,228,45*75

Where:
      GSV          Satellites in view
      2            Number of sentences for full data
      1            sentence 1 of 2
      08           Number of satellites in view

      01           Satellite PRN number
      40           Elevation, degrees
      083          Azimuth, degrees
      46           SNR - higher is better
           for up to 4 satellites per sentence
      *75          the checksum data, always begins with *
*/


   /*
   ** GSV - GPS satellite Status
   **
   **        1 2 3 4 5 6 7         n
   **        | | | | | | |         |
   ** $--GSV,x,x,x,x,x,x,x.........*hh<CR><LF>
   **
   ** Field Number:
   **  1) Number of sentences for full data
   **  2) sentence number
   **  3) Number of satellites in view
   **  4) Satellite PRN number
   **  5) Elevation, degrees
   **  6) Azimuth, degrees
   **  7) SNR - higher is better
   **  Fields 4-7 may repeat up to 4 times per sentence
   **  n) Checksum
   */

   /*
   ** First we check the checksum...
   */

   int cksumFieldNr = 0;
   int satInfoCnt = 0;
   switch (sentence.GetNumberOfDataFields())
   {
   case 19:
         cksumFieldNr = 20;
         satInfoCnt = 4;
         break;
   case 15:
         cksumFieldNr = 16;
         satInfoCnt = 3;
         break;
   case 11:
         cksumFieldNr = 12;
         satInfoCnt = 2;
         break;
   case 7:
         cksumFieldNr = 8;
         satInfoCnt = 1;
         break;
   default:
      SetErrorMessage( _T("Invalid Field count" ));
      return( FALSE );
   }
   if ( sentence.IsChecksumBad( cksumFieldNr ) == NTrue )
   {
      SetErrorMessage( _T("Invalid Checksum" ));
      return( FALSE );
   }

   NumberOfMessages = sentence.Integer( 1 );
   MessageNumber = sentence.Integer( 2 );
   SatsInView = sentence.Integer( 3 );

   for (int idx = 0; idx < satInfoCnt; idx++)
   {
         SatInfo[idx].SatNumber = sentence.Integer( idx*4+4 );
         SatInfo[idx].ElevationDegrees = sentence.Integer( idx*4+5 );
         SatInfo[idx].AzimuthDegreesTrue = sentence.Integer( idx*4+6 );
         SatInfo[idx].SignalToNoiseRatio = sentence.Integer( idx*4+7 );
   }

   return( TRUE );
}