javaextensions/location/tsrc/vipertestpsy/src/vipertestpsy.cpp
branchRCL_3
changeset 18 9ac0a0a7da70
parent 17 0fd27995241b
child 19 71c436fe3ce0
equal deleted inserted replaced
17:0fd27995241b 18:9ac0a0a7da70
     1 /*
       
     2 * Copyright (c) 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 // INCLUDES
       
    18 #include <e32base.h>
       
    19 #include <Lbs.h>
       
    20 #include <LbsSatellite.h>
       
    21 #include <ImplementationProxy.h>
       
    22 #include "ViperTestPsy.hrh"
       
    23 #include "EPos_CPositioner.h"
       
    24 
       
    25 // CONSTANTS
       
    26 const TReal32 KHorizontalAcc = 40;
       
    27 const TReal32 KVerticalAcc = 40;
       
    28 
       
    29 const TReal64 KLatitude = 2;
       
    30 const TReal64 KLongitude = 3;
       
    31 const TReal32 KAltitude = 200;
       
    32 
       
    33 _LIT(KPositionTime, "20801027:161600");//YYYYMMDD:HHMMSS.MMMMMM
       
    34 
       
    35 const TReal32 KSpeed = 20;
       
    36 const TReal32 KHeading = 30;
       
    37 const TReal32 KSpeedAcc = 2;
       
    38 const TReal32 KHeadingAcc = 3;
       
    39 
       
    40 const TInt KSatelliteId = 30;
       
    41 const TReal32 KAzimuth = 30;
       
    42 const TReal32 KElevation = 30;
       
    43 const TBool KIsUsed = ETrue;
       
    44 const TInt KSignalStrength = 10;
       
    45 
       
    46 const TReal32 KAzimuthOdd = 35;
       
    47 const TReal32 KElevationOdd = 35;
       
    48 const TBool KIsUsedOdd = EFalse;
       
    49 const TInt KSignalStrengthOdd = 5;
       
    50 
       
    51 const TUint KNumberOfSatellitesInView = 12;
       
    52 const TUint KNumberOfSatellitesUsed = 6;
       
    53 _LIT(KSatelliteTime, "20021027:161600");
       
    54 const TReal32 KHorizontalDoPValue = 1;
       
    55 const TReal32 KVerticalDoPValue = 2;
       
    56 const TReal32 KTimeDoPValue = 20;
       
    57 _LIT(KModuleName, "ViperTest PSY");
       
    58 
       
    59 // CLASS DECLARATION
       
    60 
       
    61 class CViperTestPsy: public CPositioner
       
    62 {
       
    63 public:
       
    64     // Constructors and destructor
       
    65 
       
    66     /**
       
    67      * Two-phased constructor.
       
    68      */
       
    69     static CViperTestPsy* NewL(TAny* aConstructionParameters);
       
    70 
       
    71     /**
       
    72      * Destructor.
       
    73      */
       
    74     ~CViperTestPsy();
       
    75 
       
    76 protected:
       
    77     // Functions from base classes
       
    78 
       
    79     /**
       
    80      * From CPositioner. Requests position info asynchronously.
       
    81      *
       
    82      * @param aPosInfo A reference to a position info object. This object
       
    83      *                 must be in scope until the request has completed.
       
    84      * @param aStatus The request status
       
    85      */
       
    86     void NotifyPositionUpdate(
       
    87         /* IN/OUT */TPositionInfoBase& aPosInfo,
       
    88         /* OUT    */TRequestStatus& aStatus);
       
    89 
       
    90     /**
       
    91      * From CPositioner. Cancels position info request.
       
    92      */
       
    93     void CancelNotifyPositionUpdate();
       
    94 
       
    95 private:
       
    96 
       
    97     /**
       
    98      * C++ default constructor.
       
    99      */
       
   100     CViperTestPsy();
       
   101 
       
   102     /**
       
   103      * By default EPOC constructor is private.
       
   104      */
       
   105     void ConstructL(TAny* aConstructionParameters);
       
   106 
       
   107     void SetTPositionInfo(TPositionInfo& aInfo);
       
   108     void SetTPositionCourseInfo(TPositionCourseInfo& aCourseInfo);
       
   109     void SetTPositionSatelliteInfo(TPositionSatelliteInfo& aSatelliteInfo);
       
   110     void SetHPositionGenericInfo(HPositionGenericInfo& aGenericInfo);
       
   111 
       
   112     // By default, prohibit copy constructor
       
   113     CViperTestPsy(const CViperTestPsy&);
       
   114     // Prohibit assigment operator
       
   115     CViperTestPsy& operator=(const CViperTestPsy&);
       
   116 
       
   117 };
       
   118 
       
   119 // ================= OTHER EXPORTED FUNCTIONS ==============
       
   120 
       
   121 const TImplementationProxy KFactoryPtr = IMPLEMENTATION_PROXY_ENTRY(
       
   122             KPosImplementationUid, CViperTestPsy::NewL);
       
   123 
       
   124 //
       
   125 // ---------------------------------------------------------
       
   126 // ImplementationGroupProxy
       
   127 // Required PSY interface.
       
   128 //
       
   129 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(
       
   130     TInt& aTableCount)
       
   131 {
       
   132     aTableCount = 1;
       
   133     return &KFactoryPtr;
       
   134 }
       
   135 
       
   136 // C++ default constructor can NOT contain any code, that
       
   137 // might leave.
       
   138 //
       
   139 CViperTestPsy::CViperTestPsy()
       
   140 {
       
   141 }
       
   142 
       
   143 // EPOC default constructor can leave.
       
   144 void CViperTestPsy::ConstructL(TAny* aConstructionParameters)
       
   145 {
       
   146     BaseConstructL(aConstructionParameters);
       
   147 }
       
   148 
       
   149 // Two-phased constructor.
       
   150 CViperTestPsy* CViperTestPsy::NewL(TAny* aConstructionParameters)
       
   151 {
       
   152     CViperTestPsy* self = new(ELeave) CViperTestPsy;
       
   153     CleanupStack::PushL(self);
       
   154     self->ConstructL(aConstructionParameters);
       
   155     CleanupStack::Pop();
       
   156     return self;
       
   157 }
       
   158 
       
   159 // Destructor
       
   160 CViperTestPsy::~CViperTestPsy()
       
   161 {
       
   162 }
       
   163 
       
   164 void CViperTestPsy::NotifyPositionUpdate(TPositionInfoBase& aPosInfo,
       
   165         TRequestStatus& aStatus)
       
   166 {
       
   167     TRequestStatus* status = &aStatus;
       
   168 
       
   169     TUid implUid =
       
   170         { KPosImplementationUid };
       
   171     aPosInfo.SetModuleId(implUid);
       
   172     TUint32 classType = aPosInfo.PositionClassType();
       
   173 
       
   174     if (classType == (classType & EPositionInfoClass))
       
   175     {
       
   176         TPositionInfo* position = static_cast<TPositionInfo*>(&aPosInfo);
       
   177         SetTPositionInfo(*position);
       
   178     }
       
   179     else if (classType & EPositionGenericInfoClass)
       
   180     {
       
   181         HPositionGenericInfo& generic =
       
   182             static_cast<HPositionGenericInfo&>(aPosInfo);
       
   183         SetHPositionGenericInfo(generic);
       
   184     }
       
   185     else
       
   186     {
       
   187         User::RequestComplete(status, KErrGeneral);
       
   188         return;
       
   189     }
       
   190 
       
   191     User::RequestComplete(status, KErrNone);
       
   192 }
       
   193 
       
   194 void CViperTestPsy::CancelNotifyPositionUpdate()
       
   195 {
       
   196 }
       
   197 
       
   198 void CViperTestPsy::SetTPositionInfo(TPositionInfo& aInfo)
       
   199 {
       
   200     TCoordinate coor(KLatitude, KLongitude, KAltitude);
       
   201     TLocality loc(coor, KHorizontalAcc, KVerticalAcc);
       
   202     TTime now;
       
   203     now.UniversalTime();
       
   204     TPosition pos(loc, now);
       
   205     aInfo.SetPosition(pos);
       
   206 }
       
   207 
       
   208 void CViperTestPsy::SetHPositionGenericInfo(HPositionGenericInfo& aGenericInfo)
       
   209 {
       
   210     SetTPositionInfo(aGenericInfo);
       
   211     if (aGenericInfo.IsRequestedField(EPositionFieldHorizontalSpeed))
       
   212     {
       
   213         aGenericInfo.SetValue(EPositionFieldHorizontalSpeed, KSpeed);
       
   214     }
       
   215     if (aGenericInfo.IsRequestedField(EPositionFieldHeading))
       
   216     {
       
   217         aGenericInfo.SetValue(EPositionFieldHeading, KHeading);
       
   218     }
       
   219 }
       
   220 
       
   221 //  End of File