omasuplasnconverterstubimpl/src/cstubsuplend.cpp
changeset 0 0ce1b5ce9557
equal deleted inserted replaced
-1:000000000000 0:0ce1b5ce9557
       
     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: Supl End
       
    15  *
       
    16  */
       
    17 
       
    18 #include <e32base.h>
       
    19 #include <e32def.h> 
       
    20 #include <e32cmn.h> 
       
    21 #include "epos_comasuplasnbase.h"
       
    22 #include "epos_comasuplasnmessagebase.h"
       
    23 #include "epos_comasuplend.h"
       
    24 #include "cstubsuplend.h"
       
    25 #include "lbs/epos_comasuplreqasstdata.h"
       
    26 #include "lbs/epos_comasuplposition.h"
       
    27 #include "lbs/epos_comasuplvelocity.h"
       
    28 #include "lbs/epos_comasuplsetcapabilities.h"
       
    29 #include "lbs/epos_comasuplpospayload.h"
       
    30 #include "epos_comasuplpos.h"
       
    31 #include "epos_comasuplsessionid.h"
       
    32 #include "epos_comasupllocationid.h"
       
    33 // -----------------------------------------------------------------------------
       
    34 // CStubSuplEnd::NewL
       
    35 // Other Items were commented in a header
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 EXPORT_C CStubSuplEnd* CStubSuplEnd::NewL()
       
    39     {
       
    40     CStubSuplEnd* self = new (ELeave) CStubSuplEnd;
       
    41     CleanupStack::PushL(self);
       
    42     self->ConstructL();
       
    43     CleanupStack::Pop();
       
    44     return self;
       
    45     }
       
    46 // -----------------------------------------------------------------------------
       
    47 // CStubSuplEnd::ConstructL
       
    48 // Other Items were commented in a header
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 void CStubSuplEnd::ConstructL()
       
    52     {
       
    53     COMASuplEnd::ConstructL();
       
    54     //Allocate memory for internal usage....
       
    55     }
       
    56 // -----------------------------------------------------------------------------
       
    57 // CStubSuplEnd::~CStubSuplEnd
       
    58 // Other Items were commented in a header
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 EXPORT_C CStubSuplEnd::~CStubSuplEnd()
       
    62     {
       
    63 
       
    64     }
       
    65 // -----------------------------------------------------------------------------
       
    66 // CStubSuplEnd::EncodeL
       
    67 // Other Items were commented in a header
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 HBufC8* CStubSuplEnd::EncodeL(TInt& aErrorCode)
       
    71     {
       
    72     aErrorCode = 0;
       
    73     HBufC8* encodedBuffer = NULL ;
       
    74     InitializeL();
       
    75     // Do actual encoding here and return encoded buffer and put appropriate error code in aErrorCode
       
    76     return encodedBuffer;
       
    77     }
       
    78 // -----------------------------------------------------------------------------
       
    79 // CStubSuplEnd::CStubSuplEnd
       
    80 // Other Items were commented in a header
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 CStubSuplEnd::CStubSuplEnd()
       
    84     {
       
    85     }
       
    86 void CStubSuplEnd::InitializeL()
       
    87     {
       
    88     if (iPosition)   //This parameter is optional in asn
       
    89         {
       
    90     InitializePosition();
       
    91         }
       
    92     }
       
    93 void CStubSuplEnd::InitializePosition()
       
    94     {
       
    95     // Retrieve mandatory parameters of Position
       
    96     // Retrieve mandatory parameters of Position
       
    97     TOMASuplUtcTime utcTime;
       
    98     TOMASuplPositionEstimate posEstimate;
       
    99 
       
   100     iPosition->GetPosition(utcTime,posEstimate );
       
   101 
       
   102     TInt error = 0;
       
   103 
       
   104     //Initialize Time
       
   105     InitializeTime(utcTime);
       
   106 
       
   107     InitializePositionEstimate(posEstimate);
       
   108 
       
   109     if(error)
       
   110         {
       
   111         return;
       
   112         }
       
   113     else
       
   114         {
       
   115         COMASuplVelocity* velocity = NULL;
       
   116         error = iPosition->GetVelocity(velocity);
       
   117         if(error)
       
   118             {
       
   119             //return error
       
   120             }
       
   121         else
       
   122             {
       
   123 
       
   124             TOMASuplVelocityType velocityType = velocity->VelType();
       
   125             COMASuplHorizVelocity* horizVelocity = velocity->Velocity();
       
   126             if(horizVelocity)
       
   127                 {
       
   128                 switch(velocityType)
       
   129                     {
       
   130                     case EHorizVelocity:
       
   131                         {
       
   132                         //Initialize Horizontal velocity
       
   133                         IntializeHorizVelocity(horizVelocity);
       
   134                         break;      
       
   135                         }
       
   136                     case EHorizAndVertVelocity:
       
   137                         {
       
   138                         //Initialize Horizontal and Vertical velocity
       
   139                         IntializeHorizAndVertVelocity(horizVelocity);
       
   140                         break;
       
   141                         }
       
   142                     case EHorizUncertVelocity:
       
   143                         {
       
   144                         //Initialize Horizontal Uncert velocity
       
   145                         IntializeHorizUncertVelocity(horizVelocity);
       
   146                         break;
       
   147                         }
       
   148                     case EHorizAndVertUncertVelocity:
       
   149                         {
       
   150                         //Initialize Horizontal Vertical Uncert velocity
       
   151                         IntializeHorizVertUncertVelocity(horizVelocity);
       
   152                         break;  
       
   153                         }
       
   154                     default:
       
   155                         {
       
   156                         //error
       
   157                         return;         
       
   158                         }
       
   159                     }   
       
   160                 }
       
   161             else
       
   162                 {
       
   163                 //error
       
   164                 return; 
       
   165                 }
       
   166             }
       
   167         }
       
   168     }
       
   169 
       
   170 void CStubSuplEnd::IntializeHorizVelocity(const COMASuplHorizVelocity* aVelocity)
       
   171     {
       
   172     TUint16 bearing;
       
   173     TUint16 horSpeed;
       
   174 
       
   175     aVelocity->GetHorizVel(bearing,horSpeed);
       
   176 
       
   177     //Initialize bearing,horSpeed
       
   178     }
       
   179 
       
   180 void CStubSuplEnd::IntializeHorizAndVertVelocity(const COMASuplHorizVelocity* aVelocity)
       
   181     {
       
   182     TUint16 bearing;
       
   183     TUint16 horSpeed;
       
   184     TUint8 verDirect;
       
   185     TUint8 verSpeed;
       
   186 
       
   187     COMASuplHorizAndVertVelocity* horizVertVel = (COMASuplHorizAndVertVelocity*)aVelocity;
       
   188 
       
   189     horizVertVel->GetHorizAndVertVel(bearing,horSpeed,verDirect,verSpeed);
       
   190 
       
   191     //Initialize bearing,horSpeed,verDirect,verSpeed
       
   192     }
       
   193 
       
   194 void CStubSuplEnd::IntializeHorizUncertVelocity(const COMASuplHorizVelocity* aVelocity)
       
   195     {
       
   196     TUint16 bearing;
       
   197     TUint16 horSpeed;
       
   198     TUint8 uncertSpeed;
       
   199 
       
   200     COMASuplHorizUncertVelocity* horizUncertVel = (COMASuplHorizUncertVelocity*)aVelocity;
       
   201 
       
   202     horizUncertVel->GetHorizUncertVel(bearing,horSpeed,uncertSpeed);
       
   203     //Initialize bearing,horSpeed,uncertSpeed
       
   204     }
       
   205 
       
   206 void CStubSuplEnd::IntializeHorizVertUncertVelocity(const COMASuplHorizVelocity* aVelocity)
       
   207     {
       
   208     TUint16 bearing;
       
   209     TUint16 horSpeed;
       
   210     TUint8  verDirect;
       
   211     TUint8  verSpeed;
       
   212     TUint8  horizUncertSpeed;
       
   213     TUint8  vertUncertSpeed;
       
   214 
       
   215     COMASuplHorizAndVertUncertVelocity* horizVertUncertVel = (COMASuplHorizAndVertUncertVelocity*)aVelocity;
       
   216 
       
   217     horizVertUncertVel->GetHorizVertUncertVel(bearing,horSpeed,verDirect,verSpeed,
       
   218             horizUncertSpeed,vertUncertSpeed);
       
   219     //Initialize bearing,horSpeed,verDirect,verSpeed,horizUncertSpeed,vertUncertSpeed
       
   220     }
       
   221 
       
   222 void CStubSuplEnd::InitializePositionEstimate(TOMASuplPositionEstimate& aPosEstimate)
       
   223     {
       
   224     TInt error;
       
   225 
       
   226     // Retrieve mandatory parametrs of Position Estimate
       
   227     TOMASuplPositionEstimate::TOMASuplLatitudeSign  latSign;
       
   228     TInt               latitude;
       
   229     TInt               longitude;
       
   230     aPosEstimate.GetPositionEstimate(latSign,latitude,longitude);   
       
   231 
       
   232     // Set Position Estimate
       
   233     if(KLatitudeMin <= latitude && latitude <= KLatitudeMax)
       
   234         {
       
   235         //Initialize
       
   236         }
       
   237     else
       
   238         {
       
   239         //error
       
   240         }
       
   241 
       
   242     if(KLongitudeMin <= longitude && longitude <= KLongitudeMax)
       
   243         {
       
   244         //Initialize
       
   245         }
       
   246     else
       
   247         {
       
   248         //error
       
   249         }
       
   250 
       
   251     //Initialize
       
   252 
       
   253     // Retrieve optional parametrs of Position Estimate
       
   254     // Retrieve Uncertainity
       
   255     TOMASuplUncertainty uncertainty;
       
   256     error = aPosEstimate.GetUncertainty(uncertainty);
       
   257     if(!error)
       
   258         {    
       
   259         TInt uncertSemiMajor;
       
   260         TInt uncertSemiMinor;
       
   261         TInt orientMajorAxis;
       
   262         uncertainty.GetUncertainty(uncertSemiMajor,uncertSemiMinor,orientMajorAxis);
       
   263         if((KUncertSemiMajorMin <= uncertSemiMajor && uncertSemiMajor<= KUncertSemiMajorMax)
       
   264                 && (KUncertSemiMinorMin <= uncertSemiMinor && uncertSemiMinor<= KUncertSemiMinorMax)
       
   265                 && (KOrientMajorAxisMin <= orientMajorAxis && orientMajorAxis<= KOrientMajorAxisMax))
       
   266             {
       
   267             //Initialize
       
   268             }
       
   269         else
       
   270             {
       
   271             //error
       
   272             }
       
   273         }
       
   274     else
       
   275         {
       
   276         //return error
       
   277         }
       
   278 
       
   279     // Retrieve Confidence
       
   280     TInt confidence;
       
   281     error = aPosEstimate.GetConfidence(confidence);
       
   282     if(!error)
       
   283         {
       
   284 
       
   285         if(KConfidenceMin <= confidence && confidence <= KConfidenceMax)
       
   286             {
       
   287             //Initialize       
       
   288             }
       
   289         else
       
   290             {
       
   291             //error 
       
   292             }
       
   293         }
       
   294     else
       
   295         {
       
   296         //return error
       
   297         }
       
   298 
       
   299     // Retrieve AltitudeInfo
       
   300     TOMASuplAltitudeInfo altitudeInfo;
       
   301     error = aPosEstimate.GetAltitudeInfo(altitudeInfo);
       
   302     if(!error)
       
   303         {
       
   304 
       
   305         TOMASuplAltitudeInfo::TOMASuplAltitudeDirection altDirection;
       
   306         TInt altitude;
       
   307         TInt altUncert;
       
   308         altitudeInfo.GetAltitudeInfo(altDirection,altitude,altUncert);
       
   309         if((KAltitudeMin <= altitude && altitude<= KAltitudeMax) && (KAltitudeUncertMin <= altUncert && altUncert<= KAltitudeUncertMax))
       
   310             {
       
   311             //Initialize
       
   312             }
       
   313         else
       
   314             {
       
   315             //error
       
   316             }
       
   317         }
       
   318     else
       
   319         {
       
   320         //return error
       
   321         }
       
   322 
       
   323     }
       
   324 
       
   325 void CStubSuplEnd::InitializeTime(const TOMASuplUtcTime aUtcTime)
       
   326     {
       
   327 
       
   328     TDateTime lDateTime;
       
   329     TInt      zoneCode;
       
   330     TInt      zone;
       
   331 
       
   332     aUtcTime.GetUtcTime(lDateTime,zoneCode,zone);
       
   333 
       
   334     TInt   year     = lDateTime.Year();
       
   335     TMonth month    = lDateTime.Month(); 
       
   336     TInt   day      = lDateTime.Day();
       
   337     TInt   hour     = lDateTime.Hour();
       
   338     TInt   minute   = lDateTime.Minute();
       
   339     TInt   second   = lDateTime.Second();
       
   340     TInt   microsec = lDateTime.MicroSecond();
       
   341 
       
   342     if(0 == zoneCode || 1 == zoneCode)
       
   343         {
       
   344         //Initialize 
       
   345         }
       
   346     else
       
   347         {
       
   348         //error
       
   349         }
       
   350 
       
   351 
       
   352     }