datasourcemodules/simulationpositioningmodule/inc/EPos_CPosNmeaController.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 CPOSNMEACONTROLLER_H
       
    21 #define CPOSNMEACONTROLLER_H
       
    22 
       
    23 // INCLUDES
       
    24 // #include <e32base.h>
       
    25 #include <lbspositioninfo.h>
       
    26 #include "EPos_CPosControllerBase.h"
       
    27 #include "EPos_CPosSimulationPositioner.h"
       
    28 #include "EPos_TNmeaSentenceParser.h"
       
    29 #include "EPos_SimPsyConstants.h"
       
    30 
       
    31 // CONSTANTS
       
    32 // A limit to number of reads from a Nmea file
       
    33 const TInt KMaxReads = 30;
       
    34 
       
    35 // FORWARD DECLARATIONS
       
    36 class CPosFileHandler;
       
    37 
       
    38 /**
       
    39  *
       
    40  * A controller class that handles nmea requests.
       
    41  *
       
    42  */
       
    43 class CPosNmeaController : public CPosControllerBase
       
    44     {
       
    45     public:  // Constructors and destructor
       
    46 
       
    47         /**
       
    48         * Two-phased constructor.
       
    49         *
       
    50         * @param aNMEAFile The name of the NMEA file to read from.
       
    51         * @param aTimeRelativePlayback turns on/off time related playback feature
       
    52         */
       
    53         static CPosNmeaController* NewL(
       
    54         /* IN  */       const TDesC& aNMEAFile,
       
    55         /* IN  */       TBool aTimeRelativePlayback
       
    56         );
       
    57 
       
    58         /**
       
    59         * Destructor.
       
    60         */
       
    61         virtual ~CPosNmeaController();
       
    62 
       
    63     public: // From base classes
       
    64 
       
    65         /**
       
    66         * From CPosControllerBase. Requests position info asynchronously.
       
    67         *
       
    68         * @param aPosInfo A reference to a position info object. This object
       
    69         *                 must be in scope until the request has completed.
       
    70         * @param aStatus The request status.
       
    71         * @param aSimPos Positioner which called this function
       
    72         */
       
    73         void NotifyPositionUpdate(
       
    74         /* IN/OUT */    TPositionInfoBase& aPosInfo,
       
    75         /* OUT    */    TRequestStatus& aStatus,
       
    76         /* IN     */	CPosSimulationPositioner& aSimPos
       
    77         );
       
    78 
       
    79     private:  // Constructors and destructor
       
    80 
       
    81         /**
       
    82         * C++ default constructor.
       
    83         */
       
    84         CPosNmeaController(TBool aTimeRelativePlayback);
       
    85 
       
    86         /**
       
    87         * EPOC constructor.
       
    88         *
       
    89         * @param aNMEAFile The name of the NMEA file to read from.
       
    90         */
       
    91         void ConstructL(
       
    92         /* IN  */       const TDesC& aNMEAFile
       
    93         );
       
    94 
       
    95         // Prohibit copy constructor
       
    96         CPosNmeaController( const CPosNmeaController& );
       
    97         // Prohibit assigment operator
       
    98         CPosNmeaController& operator= ( const CPosNmeaController& );
       
    99 
       
   100     private:  // New functions
       
   101 
       
   102         /**
       
   103         * Completes all requests with the specified error code
       
   104         * @param aErrorCode The error code - KErrNone if everything went OK.
       
   105         * If error code is something else, the position is invalid.
       
   106         */
       
   107         void CompleteRequest(TInt aErrorCode);
       
   108 
       
   109         /**
       
   110         * Reads an Nmea sentence from file.
       
   111         */
       
   112         void ReadSentence();
       
   113 
       
   114         /**
       
   115         * Parses an Nmea sentence in parser.
       
   116         */
       
   117         void ParseSentence();
       
   118 
       
   119         /**
       
   120         * Checks whether a position is partial or not.
       
   121         *
       
   122         * @param aPosInfo A position info object.
       
   123         * @return ETrue if position is partial, EFalse otherwise.
       
   124         */
       
   125         TBool IsPartialPosition(
       
   126         /* IN/OUT */    TPositionInfoBase& aPosInfo
       
   127         );
       
   128 
       
   129         /**
       
   130         * Checks if Simulation PSY should complete request or if parser
       
   131         * and position should be resetted and another try to get a
       
   132         * full fix should be started.
       
   133         */
       
   134         void CompleteOrRetry();
       
   135         /**
       
   136          * Kicks timer to trigger RunL in CPosControllerBase::iTimeBetweenReads
       
   137          */
       
   138         void StartTrpDelayTimer();
       
   139 
       
   140     private: // Functions from base classes
       
   141 
       
   142         /**
       
   143         * From CActive. Handles an active object’s request completion
       
   144         * event.
       
   145         */
       
   146         void RunL();
       
   147 
       
   148         /**
       
   149         * From CActive. Implements cancellation of an outstanding
       
   150         * request.
       
   151         */
       
   152         void DoCancel();
       
   153 
       
   154     private:    // Data
       
   155     	enum ENmeaControllerState
       
   156     		{
       
   157     		EIdle,
       
   158     		EWaiting,
       
   159     		EReadingSentence,
       
   160     		EParsingSentence,
       
   161     		
       
   162     		};
       
   163         //Buffer for storing last read sentence
       
   164         TBuf8<KMaxSentenceLength> iInputBuffer;
       
   165 
       
   166         //Pointer to the instance of CPosFileHandler object
       
   167         CPosFileHandler* iFileHandler;
       
   168 
       
   169         //Instance of TNmeaSentenceParser object
       
   170         TNmeaSentenceParser iParser;
       
   171 
       
   172         TBool iHasAlreadyReadFirstSentence;
       
   173         /**
       
   174          * Timer object used to provide time relative playback (TRP) feature.
       
   175          * When working in TRP mode it triggers reads from NMEA data file
       
   176          * every CPosControllerBase::iTimeBetweenReads
       
   177          */
       
   178         RTimer	iTimerTrigger;
       
   179         /**
       
   180          * Defines state of current object
       
   181          */
       
   182         ENmeaControllerState iState;
       
   183         
       
   184     };
       
   185 
       
   186 #endif      // CPOSNMEACONTROLLER_H
       
   187 
       
   188 // End of File