basiclocationinfodisplay/blid/engine/inc/CBlidLocation.h
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     1 /*
       
     2 * Copyright (c) 2005 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:  Provides access to Blid location.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CBLIDLOCATION_H
       
    21 #define CBLIDLOCATION_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <lbspositioninfo.h>
       
    26 #include <lbs.h>
       
    27 #include <lbssatellite.h>
       
    28 #include "MBlidLocation.h"
       
    29 #include "CBlidEng.h"
       
    30 
       
    31 // CLASS DECLARATION
       
    32 class CBlidModuleinfoObserver;
       
    33 
       
    34 
       
    35 /**
       
    36 *  A Blid engine API for blid application.
       
    37 *  Provides access to blid location.
       
    38 *  This class implements the MBlidLocation interface provided by this dll.
       
    39 *
       
    40 */
       
    41 class CBlidLocation : public CActive, public MBlidLocation
       
    42     {
       
    43     public:  // Constructors and destructor
       
    44         /**
       
    45          * Two-phased constructor.
       
    46          * @param aServer RPositionServer variable
       
    47          */
       
    48         static CBlidLocation* NewL( RPositionServer& aServer, CBlidEng& aEngine );
       
    49 
       
    50         /**
       
    51          * Destructor.
       
    52          */
       
    53         virtual ~CBlidLocation();
       
    54         
       
    55         void TimerCallBackL();
       
    56 
       
    57     private:
       
    58         /**
       
    59          * C++ default constructor.
       
    60          * @param aServer RPosition variable
       
    61          */
       
    62         CBlidLocation( RPositionServer& aServer,CBlidEng& aEngine );
       
    63 
       
    64         /**
       
    65          * By default Symbian 2nd phase constructor is private.
       
    66          */
       
    67         void ConstructL();
       
    68 
       
    69     private: // From MBlidLocation
       
    70         //Current view Id needed to set the update options accordingly.
       
    71         void SetObserver(MBlidEngObserver& aObserver, TInt aViewId);
       
    72         void RemoveModelObserver();
       
    73         void InitialLocationRequestL( const TDesC& aSrvName );
       
    74         TPosition& GetCurrentPosition();
       
    75         TCourse& GetCourse();
       
    76         void CancelRequest();
       
    77         void StopRequesting();
       
    78         void StartRequesting();
       
    79         TBool IsOnline();
       
    80         TBool SatelliteCapability();
       
    81         TReal SpeedAverage();
       
    82         TInt GetPositionInfoStatus() ;
       
    83         TReal MaxSpeed();
       
    84         void ResetMaxSpeed();
       
    85         void ResetAvgSpeed();
       
    86         void GetModuleInfoStatus(TPositionModuleStatusBase& aPosModuleStatus);
       
    87         void GetNumOfSatellitesL(TInt& anumSatellites);
       
    88         TReal32 GetHeading();
       
    89         void CalculateCourse();        
       
    90 
       
    91         TBool WasGPSAvailableOnTripStop();
       
    92         TBool CheckIfWaitingGPSData();
       
    93         TInt GetRegisteredViewId();
       
    94         void GetModuleInfoNotificationL();
       
    95         void SetNavigationStart( TBool aNavigationStart );
       
    96         void ResetOdometerValue();
       
    97         TBool IsSatCapablePsyAvailable();
       
    98         TInt NumberOfSatellitesVisible();
       
    99         TBool IsSatellitesUsed( TInt aIndex );
       
   100         TInt GetSatelliteSignalStrength( TInt aIndex );
       
   101         TInt GetSatelliteNo( TInt aIndex );
       
   102 
       
   103     private: // From CActive
       
   104         void RunL();
       
   105         void DoCancel();
       
   106         TInt RunError(TInt aError);
       
   107         CPeriodic *iTimer;
       
   108         
       
   109     private: //New functions
       
   110     
       
   111         // Indicates the connection status to GPS device
       
   112         enum TDeviceConStatus
       
   113             {
       
   114             EDeviceConnected,
       
   115             EDeviceNotFound,
       
   116             EDeviceUnderConnection
       
   117             };
       
   118         /**
       
   119          * Update request interval time
       
   120          * @param aIntervalTime time in microseconds
       
   121          */
       
   122         void UpdateIntervalL( const TInt aIntervalTime );
       
   123         
       
   124         /**
       
   125          * Sets the update options based 
       
   126          * on the view and its conditions
       
   127          */
       
   128         void SetUpdateOptions();
       
   129 
       
   130         /**
       
   131          * Check if satellite information is available
       
   132          * @return TBool, ETrue if is capability and EFalse if not
       
   133          */
       
   134         TBool IsSatelliteCapabilityL();  
       
   135         
       
   136         /**
       
   137          * Calculates all the data for current trip
       
   138          *
       
   139          */
       
   140         void UpdateTripData();  
       
   141 
       
   142         /**
       
   143          * Calculate trip time
       
   144          * 
       
   145          */
       
   146 
       
   147         void CalculateTripTimeL( );
       
   148         
       
   149         /**
       
   150          * Calculate total time
       
   151          * 
       
   152          */
       
   153 
       
   154         void CalculateTotalTimeL( ); 
       
   155         
       
   156         /**
       
   157          * Gets the trip time
       
   158          */        
       
   159         void GetTripTime(  TTimeIntervalSeconds& aTime );  
       
   160         
       
   161         /**
       
   162          * Gets the total view time 
       
   163          */
       
   164         void GetTotalTime( TTimeIntervalSeconds& aTime );  
       
   165         
       
   166         /**
       
   167          * Check to see if any distance
       
   168          * is travelled
       
   169          */
       
   170         TBool IsTripDistanceTravelled(); 
       
   171         
       
   172         /**
       
   173          * Check to see if any distance
       
   174          * is travelled
       
   175          */
       
   176         TBool IsTotalDistanceTravelled(); 
       
   177         
       
   178         /**
       
   179          * Gets the trip
       
   180          * distance
       
   181          */
       
   182         void GetTripDistance( TReal32& aDistance ); 
       
   183         
       
   184         /**
       
   185          * Gets the total distance
       
   186          */
       
   187         void GetTotalDistance( TReal32& aDistance ); 
       
   188         
       
   189         /**
       
   190          * Set the trip start variable
       
   191          */
       
   192         void SetTripStartL() ;
       
   193         
       
   194         /**
       
   195          * Return the iIsTripStart variable
       
   196          */
       
   197         TBool HasTripStarted() ;
       
   198         
       
   199         /**
       
   200          * Set the trip stop variable
       
   201          */
       
   202         void SetTripStop() ;
       
   203         
       
   204         /**
       
   205          * Return the iIsTripNotStart variable
       
   206          */
       
   207         TBool HasTripNotStarted() ;
       
   208 
       
   209     	/**
       
   210     	 * All the display for the current trip are
       
   211     	 * reset
       
   212     	 */
       
   213         void ResetTrip();
       
   214 
       
   215         /**
       
   216     	 * Resets only the trip 
       
   217     	 *
       
   218     	 */
       
   219         void SetTripResumeL();
       
   220         
       
   221         /**
       
   222          * Set the trip clear variable
       
   223          */
       
   224         void SetTripClear( ) ;
       
   225         
       
   226         /**
       
   227          * Return the iIsTripClear variable
       
   228          */
       
   229         TBool IsTripCleared( ) ;
       
   230         
       
   231         /**
       
   232          * To set the iIsTripClear variable to false
       
   233          */
       
   234         void ResetTripClear();
       
   235         
       
   236         /**
       
   237          * Function to check if trip
       
   238          * is stopped and is reset
       
   239          */
       
   240         TBool IsTripReset();
       
   241         
       
   242         /**
       
   243          * Function to check if GPS
       
   244          * device is paired 
       
   245          */
       
   246         TInt CheckGPSAvailability();
       
   247         
       
   248         /**
       
   249          * Function to check if GPS
       
   250          * data is available. i.e 
       
   251          * if satellites are visible
       
   252          */
       
   253         TBool IsGPSDataAvailable();
       
   254         
       
   255         /**
       
   256          * Trip meter function to get the
       
   257          * average speed in the trip
       
   258          */
       
   259         TReal32 GetTripAverageSpeed();
       
   260         
       
   261         /**
       
   262          * Trip meter function to get the
       
   263          * maximum speed in the trip
       
   264          */
       
   265         TReal32 GetTripMaxSpeed();
       
   266         
       
   267         /**
       
   268          * Trip meter function to determine
       
   269          * if GPS data was lost when trip was running
       
   270          */
       
   271         TBool WasGPSDataLost();
       
   272         
       
   273         /**
       
   274          * Set function for trip meter GPS data
       
   275          * availability
       
   276          */
       
   277         void SetGPSDataAvailability(TBool aAvailability);
       
   278         
       
   279         /**
       
   280          * Function to get the current update
       
   281          * interval set
       
   282          */
       
   283         void GetCurrentUpdateInterval(TInt& aInterval);
       
   284         
       
   285         /**
       
   286          * Function to check if GPS data is awaited.
       
   287          * Returns true if connection to the GPS device is 
       
   288          * being established or if connection is being established
       
   289          * and some satellites are visible but fix not available
       
   290          */
       
   291         TBool WaitingGPSData();
       
   292         
       
   293         /**
       
   294          * Function to get the current PSY status
       
   295          * @return TBool, ETrue if is connected and EFalse if not
       
   296          */        
       
   297         TBool IsGPSDeviceConnected();
       
   298         
       
   299 		TInt GetSatelliteData( TUint aIndex, TSatelliteData& aSatelliteData); 
       
   300 		
       
   301 		void SortSatelliteDataL();       
       
   302                 
       
   303     private: // Data
       
   304         /// Ref: Observer interface to Blid application engine
       
   305         MBlidEngObserver* iObserver;
       
   306 
       
   307         ///  RPositioner
       
   308         RPositioner iPositioner;
       
   309 
       
   310         ///  TPosition
       
   311         TPosition iPosition;
       
   312 
       
   313         ///  TCource
       
   314         TCourse iCourse;
       
   315 
       
   316         ///  TPositionCourseInfo
       
   317         TPositionSatelliteInfo iPositionInfo;
       
   318                 
       
   319         /// Ref: iServer
       
   320         RPositionServer& iServer;
       
   321 
       
   322         ///  Update interval time
       
   323         TBool iUpdateInterval;
       
   324 
       
   325         ///  Start and stop requesting
       
   326         TBool iRequesting;
       
   327 
       
   328         ///  Online / Offline mode
       
   329         TBool iOnlineMode;
       
   330 
       
   331         ///  Capable of returning satellite information
       
   332         TBool iSatelliteCapability;
       
   333 
       
   334         /// TReal variable
       
   335         TReal iSpeedAverage;
       
   336 
       
   337         /// TReal variable
       
   338         TReal iMaxSpeed;
       
   339 
       
   340         /// TReal array
       
   341         RArray<TReal> iSpeedArray;
       
   342 
       
   343         /// TInt variable 
       
   344         TInt iCount;
       
   345         
       
   346         /// Bearing variable
       
   347         TInt iBearing;
       
   348 
       
   349         /// Is bearing data available
       
   350         TBool iIsBearing;
       
   351 
       
   352         /// Is Heading data available
       
   353         TBool iIsHeading;
       
   354 
       
   355         /// distance variable
       
   356         TReal32 iDistance;
       
   357 
       
   358         /// Is Distance data available
       
   359         TBool iIsDistanceTravelled;
       
   360 
       
   361         /// Is Distance data available
       
   362         TBool iIsDistance;
       
   363 
       
   364         /// duration variable
       
   365         TTime iDuration;
       
   366 
       
   367         /// duration in seconds
       
   368         TReal64 iDurationInSeconds;
       
   369 
       
   370          /// duration in seconds
       
   371         TReal64 iTotalDurationInSeconds;
       
   372         
       
   373         /// Speed variable
       
   374         TReal iSpeed;
       
   375 
       
   376         /// Is speed data available
       
   377         TBool iIsSpeed;
       
   378 
       
   379         /// Distance travelled variable
       
   380         TReal32 iDistanceTravelled;
       
   381 
       
   382         ///Total Distance travelled variable
       
   383         TReal32 iTotalDistanceTravelled;
       
   384 
       
   385         /// Trip time variable
       
   386         TTime iTripTime;
       
   387 
       
   388         /// Trip time variable
       
   389         TTime iTotalTime;
       
   390 
       
   391         /// Own: A pointer to TLocale object
       
   392         TLocale* iLocale;
       
   393         
       
   394         /// Holds the previously recorded position
       
   395         TPosition iPrevPosition; 
       
   396         
       
   397         /// Holds the previous position for course calculations
       
   398         TPosition iPrevCoursePosition;
       
   399         
       
   400         /// Holds the time at which trip meter was started
       
   401         TTime iInitTripTime;
       
   402         
       
   403          /// Is Trip Started available
       
   404         TBool iIsTripStart;
       
   405 
       
   406 		/// Is Trip Not Started available
       
   407         TBool iIsTripNotStart;
       
   408         
       
   409         /// Holds the time at which trip meter has started
       
   410         TTime iInitViewTime;
       
   411         
       
   412         /// Holds the trip meter timing
       
   413         TTimeIntervalSeconds iTripInterval;
       
   414         
       
   415         /// Holds the total time
       
   416         TTimeIntervalSeconds iTotalInterval;
       
   417         
       
   418         /// Is speed data available
       
   419         TBool iIsTripClear;
       
   420         
       
   421         /// Holds the time when Trip has stopped
       
   422         TTime iStoppedTime;
       
   423         
       
   424         // Boolean to determine if trip has been reset       
       
   425         TBool iIsTripReset;
       
   426         
       
   427         /// Request status from Location FW
       
   428         TRequestStatus iPosStatus;
       
   429         
       
   430         /// Holds the heading angle
       
   431         TReal32 iHeading;
       
   432         
       
   433         /// Boolean to detrmine if GPS data is available
       
   434         TBool iGPSDataAvailable;
       
   435         
       
   436         /// Boolean to determine if GPS data was available when
       
   437         /// trip meter was stopped
       
   438         TBool iWasGPSDataAvailableOnTripStop;
       
   439         
       
   440         // Average speed of the trip
       
   441         TReal32 iTripAverageSpeed;
       
   442         
       
   443         // Maximum speed in the trip
       
   444         TReal32 iTripMaxSpeed;
       
   445         
       
   446         // Boolean to determine if GPS data was lost when
       
   447         // trip meter was running
       
   448         TBool iTripGPSDataLost;
       
   449         
       
   450         // Id of the view registered by the
       
   451         // SetObserver API
       
   452         TInt iRegisteredViewId;
       
   453                 
       
   454         // Pointer to the engine. Needed to 
       
   455         // get pointer to the router
       
   456         CBlidEng& iEngine;
       
   457         
       
   458         // Value of the current
       
   459         // update interval set
       
   460         TInt iCurrentUpdateInterval;
       
   461         
       
   462         /// Boolean to detrmine if variable iPrevPosition 
       
   463         /// was updated to hold the appropriate previous position
       
   464         TBool iIsPreviousPositionUpdated;
       
   465         
       
   466         /// Boolean to determine if the system is waiting for GPS data
       
   467         TBool iWaitingGpsData;
       
   468         
       
   469         // Boolean to determine if the first update has been received or not
       
   470         TBool iUpdateReceived;
       
   471         
       
   472         TUint iModuleCount;
       
   473         
       
   474         RArray<TPositionModuleInfo> iModuleInfoArray;
       
   475     	
       
   476     	CBlidModuleinfoObserver*	iModuleInfoObserv;
       
   477     	
       
   478     	
       
   479     #ifdef _DEBUG
       
   480     private:
       
   481         // for testing
       
   482         friend class T_CBLIDLOCATION;
       
   483     #endif
       
   484         
       
   485         //Variable holds the PSY status.
       
   486         TDeviceConStatus iDeviceStatus;
       
   487         
       
   488         TTime            iLastGoodFixTime;
       
   489 
       
   490     	RArray<TSatelliteData> iSortedSatData;        
       
   491     };
       
   492 
       
   493 
       
   494 #endif      // CBLIDLOCATION_H
       
   495 
       
   496 // End of File