datasourcemodules/simulationpositioningmodule/inc/EPos_TNmeaSentenceParser.h
changeset 0 9cfd9a3ee49c
equal deleted inserted replaced
-1:000000000000 0:9cfd9a3ee49c
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef TNMEASENTENCEPARSER_H
       
    21 #define TNMEASENTENCEPARSER_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32math.h>
       
    25 #include <lbspositioninfo.h>
       
    26 #include <lbssatellite.h>
       
    27 #include <lbserrors.h>
       
    28 #include "EPos_TDesTokeniser.h"
       
    29 
       
    30 // CONSTANTS
       
    31 typedef TInt TNmeaSentence;
       
    32 
       
    33 const TInt KPosNotParsed = 0x0;
       
    34 const TInt KPosGGAParsed = 0x1;
       
    35 const TInt KPosGSAParsed = 0x2;
       
    36 const TInt KPosRMCParsed = 0x4;
       
    37 const TInt KPosGLLParsed = 0x8;
       
    38 
       
    39 const TInt KPosErrorAlreadyParsed = 2000;
       
    40 const TInt KPosErrorNotValidNMEASentence = KErrNone;
       
    41 const TInt KPosAllParsed = KPosGGAParsed |
       
    42                            KPosGSAParsed |
       
    43                            KPosRMCParsed |
       
    44                            KPosGLLParsed;
       
    45 
       
    46 // CLASS DECLARATION
       
    47 
       
    48 /**
       
    49  * Parses NMEA sentences.
       
    50  */
       
    51 class TNmeaSentenceParser
       
    52     {
       
    53     public:  // Constructors and destructor
       
    54 
       
    55         /**
       
    56          * Default C++ constructor.
       
    57          */
       
    58         TNmeaSentenceParser();
       
    59 
       
    60     public: // New functions
       
    61 
       
    62         /**
       
    63          * Parses a sentence and places result in the attached position.
       
    64          * If no position is attached a position will be allocated.
       
    65          *
       
    66          * @param  aSentence The sentence to parse
       
    67          * @param  aPosition Position data will be put here
       
    68          * @param  aConst When set to ETrue doesn't change the state of the object.
       
    69          * 			Allows getting the same information as for previous call to this function
       
    70          * 			without changing the state. Is used to feed more then one TPositionInfo data
       
    71          * 			in loop with the same data.
       
    72          * @return an error code
       
    73          */
       
    74         TInt ParseSentence(
       
    75         /* IN  */       const TDesC8&       aSentence,
       
    76         /* IN OUT */    TPositionInfo&      aPosInfo, 
       
    77         /* IN  */       TBool aConst=EFalse
       
    78         );
       
    79 
       
    80         /**
       
    81          * Returns the progress made.
       
    82          *
       
    83          * @return TInt with bits set to represent the sentences that have
       
    84          * been parsed.
       
    85          */
       
    86         TInt Progress();
       
    87 
       
    88         /**
       
    89          * Resets the internal state of the parser.
       
    90          */
       
    91         void Reset();
       
    92 
       
    93     protected:  // New functions
       
    94 
       
    95         /**
       
    96          * Returns the type of an NMEA sentence.
       
    97          *
       
    98          * @param  aSentence The sentence to parse.
       
    99          * @return The sentence type.
       
   100          */
       
   101         TNmeaSentence SentenceType(const TDesC8& aSentence);
       
   102 
       
   103         /**
       
   104          * Parses a GGA NMEA sentence.
       
   105          *
       
   106          * @param  aSentence The sentence to parse
       
   107          * @param  aPositionInfo An object that can store position data.
       
   108          * @return KErrNone if parsed successfully.
       
   109          */
       
   110         TInt ParseGGA(
       
   111         /* IN  */       const TDesC8&   aSentence,
       
   112         /* IN OUT */    TPositionInfo&  aPositionInfo
       
   113         );
       
   114 
       
   115         /**
       
   116          * Parses a RMC NMEA sentence.
       
   117          *
       
   118          * @param  aSentence The sentence to parse.
       
   119          * @param  aPositionInfo An object that can store position data.
       
   120          * @return KErrNone if parsed successfully.
       
   121          */
       
   122         TInt ParseRMC(
       
   123         /* IN  */       const TDesC8&   aSentence,
       
   124         /* IN OUT */    TPositionInfo&  aPositionInfo
       
   125         );
       
   126 
       
   127         /**
       
   128          * Parses a GSA NMEA sentence.
       
   129          *
       
   130          * @param aSentence The sentence to parse.
       
   131          * @param aPositionInfo An object that can store GPS specific
       
   132          * position data
       
   133          * @return KErrNone if parsed successfully.
       
   134          */
       
   135         TInt ParseGSA(
       
   136         /* IN  */       const TDesC8&   aSentence,
       
   137         /* IN OUT */    TPositionInfo&  aPositionInfo
       
   138         );
       
   139 
       
   140         /**
       
   141          * Parses a GSV NMEA sentence.
       
   142          *
       
   143          * @param aSentence The sentence to parse.
       
   144          * @param aPositionInfo An object that can store GPS specific
       
   145          * position data
       
   146          * @param  aConst When set to ETrue doesn't change the state of the object.
       
   147          * 			Allows getting the same information as for previous call to this function
       
   148          * 			without changing the state. Is used to feed more then one TPositionInfo data
       
   149          * 			in loop with the same data.
       
   150          * @return KErrNone if parsed successfully.
       
   151          */
       
   152         TInt ParseGSV(
       
   153         /* IN  */       const TDesC8&   aSentence,
       
   154         /* IN OUT */    TPositionInfo&  aPositionInfo,
       
   155         /* IN  */       TBool aConst=EFalse
       
   156         );
       
   157 
       
   158         /**
       
   159          * Parses a PGRMM NMEA sentence.
       
   160          *
       
   161          * @param aSentence The sentence to parse.
       
   162          * @param aPositionInfo An object that can store position data.
       
   163          * @return KErrNone if parsed successfully.
       
   164          */
       
   165         TInt ParsePGRMM(
       
   166         /* IN  */       const TDesC8&   aSentence,
       
   167         /* IN OUT */    TPositionInfo&  aPositionInfo
       
   168         );
       
   169 
       
   170     private:
       
   171     	/**
       
   172 		 * Adding NMEA sentence to position info object 
       
   173 		 *
       
   174 		 * @param aPositionGenericInfo An object that can store position data.
       
   175 		 * @param aSentence The sentence to parse.
       
   176 		 * @param  aConst When set to ETrue doesn't change the state of the object.
       
   177          * 			Allows getting the same information as for previous call to this function
       
   178          * 			without changing the state. Is used to feed more then one TPositionInfo data
       
   179          * 			in loop with the same data.
       
   180 		 * @return KErrNone if parsed successfully.
       
   181 		 */
       
   182         TInt AddNmeaSentence(
       
   183             HPositionGenericInfo& aPositionGenericInfo,
       
   184             const TDesC8& aSentence, TBool aConst=EFalse);
       
   185 
       
   186         void ToCoordinate(
       
   187             const TDesC8& aDes,
       
   188             const TDesC8& aDir,
       
   189             TReal& aCoordinate);
       
   190 
       
   191         TInt DesToInt(const TPtrC8& aDes);
       
   192 
       
   193         TReal DesToReal(const TPtrC8& aDes);
       
   194 
       
   195         TReal32 DesToFloat(const TPtrC8& aDes);
       
   196 
       
   197         TBool VerifyChecksum(const TDesC8& aSentence);
       
   198 
       
   199         TUint8 CharToNibble(const TUint8 aChar);
       
   200 
       
   201         TInt GetSatelliteListIndex(
       
   202             const TPositionSatelliteInfo& aSatInfo,
       
   203             TInt aPrnNumber,
       
   204             TInt& aIndex
       
   205         );
       
   206 
       
   207         TInt UpdateSatDataInList(
       
   208             TPositionSatelliteInfo& aSatInfo,
       
   209             TSatelliteData aSatData,
       
   210             TInt aIndex
       
   211         );
       
   212 
       
   213     private:    // Data
       
   214         TInt                            iProgress;
       
   215         TInt                            iGSVIndex;
       
   216         TUint8                          iNumNmeaSentences;
       
   217     };
       
   218 
       
   219 #endif      // TNMEASENTENCEPARSER_H
       
   220 
       
   221 // End of File