lbstest/lbstestproduct/lbssimulationpsy/src/ctlbssimulationpsypostp500.cpp
changeset 0 9cfd9a3ee49c
equal deleted inserted replaced
-1:000000000000 0:9cfd9a3ee49c
       
     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 
       
    18 
       
    19 #include "ctlbssimulationpsypostp500.h"
       
    20 #include "simulationpsyinternalcrkeys.h"
       
    21 
       
    22 // Number of tests in this file, increment when a new test is added
       
    23 const TInt KNrOfTests = 8;
       
    24 // Small variances in the timing can cause the returned position to be slightly different; 
       
    25 // This constant compensates for that difference. 
       
    26 const TReal KMaxDev = 0.00005;
       
    27 // Period of wait between requests
       
    28 const TInt KTimeToWaitBetweenRequests = 2000000; //time in microseconds
       
    29 
       
    30 
       
    31 _LIT(KName0, "TP500-0 - CommonDataSequentialAccessNmea");
       
    32 _LIT(KName1, "TP500-1 - CommonDataSimultaneousAccessNmea");
       
    33 _LIT(KName2, "TP500-2 - CommonDataSequentialAccessSps");
       
    34 _LIT(KName3, "TP500-3 - CommonDataSimultaneousAccessSps");
       
    35 _LIT(KName4, "TP300-4 - ChangeDataSetToIndependent");
       
    36 _LIT(KName5, "TP300-5 - ChangeDataSetToCommon");
       
    37 _LIT(KName6, "TP300-6 - MultipleRequestPartialUpdateNmea");
       
    38 _LIT(KName7, "TP300-7 - PartialUpdateNmea");
       
    39 // Data files
       
    40 #ifdef __WINS__
       
    41 _LIT(KSimulationSource, "z:\\system\\test\\testdata\\simulationMoveNoError.sps");
       
    42 _LIT(KMagellanTracker, "z:\\system\\test\\testdata\\MagellanTracker.nme");
       
    43 #else
       
    44 _LIT(KSimulationSource, "c:\\system\\test\\testdata\\simulationMoveNoError.sps");
       
    45 _LIT(KMagellanTracker, "c:\\system\\test\\testdata\\MagellanTracker.nme");
       
    46 #endif
       
    47 
       
    48 _LIT(KService, "service");
       
    49 
       
    50 CT_LbsSimulationPsyPosTp500::CT_LbsSimulationPsyPosTp500(CT_LbsServer& aParent,
       
    51 		TInt aIndex) :
       
    52 	CT_LbsPortedStepBase(aParent)
       
    53 	{
       
    54 	iIndex = aIndex;
       
    55 	}
       
    56 
       
    57 void CT_LbsSimulationPsyPosTp500::StartL()
       
    58 	{
       
    59 	// Setup test environment
       
    60 	SetTestStepName(GetIndexNameL(iIndex));
       
    61 	iNrOfRequests = 0;
       
    62 	ConnectL();
       
    63 	SetupPsyL(iUidSimulationPsy);
       
    64 	RunTestsL(iIndex);
       
    65 	}
       
    66 
       
    67 /*
       
    68  * From CT_LbsPortedStepBase
       
    69  * Cleans up after a test.
       
    70  * Always called, even if the test leaves.
       
    71  */
       
    72 void CT_LbsSimulationPsyPosTp500::CloseTest()
       
    73 	{
       
    74 	SetCommonDataSetL(iOldTrpMode);
       
    75 	ClosePositioner();
       
    76 	Disconnect();
       
    77 	}
       
    78 
       
    79 /*
       
    80  * Gets the name of an individual test index
       
    81  * @param aIndex Indicates which test index name that is asked for.
       
    82  */
       
    83 TPtrC CT_LbsSimulationPsyPosTp500::GetIndexNameL(TInt aIndex) const
       
    84 	{
       
    85 	if (aIndex > KNrOfTests)
       
    86 		{
       
    87 		User::Leave(KErrGeneral);
       
    88 		}
       
    89 
       
    90 	const TDesC* names[KNrOfTests] =
       
    91 		{
       
    92 		&KName0, &KName1, &KName2, &KName3, &KName4, &KName5, &KName6, &KName7
       
    93 		};
       
    94 	return *names[aIndex];
       
    95 	}
       
    96 
       
    97 /*
       
    98  * Contains calls to tests itself. 
       
    99  * @param aIndex test number
       
   100  */
       
   101 void CT_LbsSimulationPsyPosTp500::RunTestsL(TInt aIndex)
       
   102 	{
       
   103 	_LIT(KStart, "Testing CommonDataSequentialAccessNmea PSY ");
       
   104 	_LIT(KStart1, "Testing CommonDataSimultaneousAccessNmea PSY ");
       
   105 	_LIT(KStart2, "Testing CommonDataSequentialAccessSps PSY ");
       
   106 	_LIT(KStart3, "Testing CommonDataSimultaneousAccessSps PSY ");
       
   107 	_LIT(KStart4, "Testing ChangeDataSetToIndependent PSY ");
       
   108 	_LIT(KStart5, "Testing ChangeDataSetToCommon PSY ");
       
   109 	_LIT(KStart6, "Testing MultipleRequestPartialUpdateNmea PSY ");
       
   110 	_LIT(KStart7, "Testing PartialUpdateNmea PSY ");
       
   111 	_LIT(KEnd, "CommonDataSequentialAccessNmea passed");
       
   112 	_LIT(KEnd1, "CommonDataSimultaneousAccessNmea passed");
       
   113 	_LIT(KEnd2, "CommonDataSequentialAccessSps passed");
       
   114 	_LIT(KEnd3, "CommonDataSimultaneousAccessSps passed");
       
   115 	_LIT(KEnd4, "ChangeDataSetToIndependent passed");
       
   116 	_LIT(KEnd5, "ChangeDataSetToCommon passed");
       
   117 	_LIT(KEnd6, "MultipleRequestPartialUpdateNmea passed");
       
   118 	_LIT(KEnd7, "PartialUpdateNmea passed");
       
   119 
       
   120 	GetCommonDataSetL(iOldTrpMode);
       
   121 	switch (aIndex)
       
   122 		{
       
   123 		case 0:
       
   124 			INFO_PRINTF1(KStart);
       
   125 			TestMultipleClientAccessL(ETrue);
       
   126 			INFO_PRINTF1(KEnd);
       
   127 			break;
       
   128 		case 1:
       
   129 			INFO_PRINTF1(KStart1);
       
   130 			TestMultipleClientAccessL(ETrue, ETrue);
       
   131 			INFO_PRINTF1(KEnd1);
       
   132 			break;
       
   133 		case 2:
       
   134 			INFO_PRINTF1(KStart2);
       
   135 			TestMultipleClientAccessL(EFalse);
       
   136 			INFO_PRINTF1(KEnd2);
       
   137 			break;
       
   138 		case 3:
       
   139 			INFO_PRINTF1(KStart3);
       
   140 			TestMultipleClientAccessL(EFalse, ETrue);
       
   141 			INFO_PRINTF1(KEnd3);
       
   142 			break;
       
   143 		case 4:
       
   144 			INFO_PRINTF1(KStart4);
       
   145 			TestMultipleClientChangeDataModeL(EFalse, ETrue);
       
   146 			INFO_PRINTF1(KEnd4);
       
   147 			break;
       
   148 		case 5:
       
   149 			INFO_PRINTF1(KStart5);
       
   150 			TestMultipleClientChangeDataModeL(ETrue, EFalse);
       
   151 			INFO_PRINTF1(KEnd5);
       
   152 			break;
       
   153 		case 6:
       
   154 			INFO_PRINTF1(KStart6);
       
   155 			TestMultipleClientPartialFixL();
       
   156 			INFO_PRINTF1(KEnd6);
       
   157 			break;
       
   158 		case 7:
       
   159 			INFO_PRINTF1(KStart7);
       
   160 			TestNmeaPartialFixL();
       
   161 			INFO_PRINTF1(KEnd7);
       
   162 			break;
       
   163 		default:
       
   164 			User::Leave(KErrArgument);
       
   165 		}
       
   166 	}
       
   167 
       
   168 void CT_LbsSimulationPsyPosTp500::TestMultipleClientAccessL(
       
   169 		const TBool aIsNmea, const TBool aSimultaneousRequest,
       
   170 		const TBool aCommonDataSet,
       
   171 		const TBool aSwitchDataMode)
       
   172 	{
       
   173 	_LIT(KError1, "Error when requesting location");
       
   174 	_LIT(KError2, "Time out error");
       
   175 	_LIT(KSetUpdateOptionsErr, "Error %d when setting Max Update Age option.");
       
   176 	_LIT(KGetUpdateOptionsErr, "Error %d when getting update options.");
       
   177 	//Max allowed number of loop runs
       
   178 	const TInt KMaxNumberOfTests = 50;
       
   179 
       
   180 	// Set data file
       
   181 	if (!aIsNmea)
       
   182 		{
       
   183 		SetSimDataFileL(KSimulationSource);
       
   184 		}
       
   185 	else
       
   186 		{
       
   187 		SetSimDataFileL(KMagellanTracker);
       
   188 		}
       
   189 
       
   190 	SetCommonDataSetL(aCommonDataSet); // set common data mode
       
   191 
       
   192 	RPositioner secondPositioner;
       
   193 	TInt err = KErrNone;
       
   194 
       
   195 	TPositionInfo posInfo1;
       
   196 	TPositionInfo posInfo2;
       
   197 
       
   198 	OpenPositionersLC(secondPositioner);
       
   199 	
       
   200 	//setting max update age for 0, for iPositioner
       
   201 	TPositionUpdateOptions posOption;
       
   202 	TInt err2 = iPositioner.GetUpdateOptions(posOption);
       
   203 	AssertTrueL(err2 == KErrNone, KGetUpdateOptionsErr, err2);
       
   204 	posOption.SetMaxUpdateAge(0);
       
   205 	err2 = iPositioner.SetUpdateOptions(posOption);
       
   206 	AssertTrueL(err2 == KErrNone, KSetUpdateOptionsErr, err2);
       
   207 	
       
   208 	//setting max update age for 0, for second positioner
       
   209 	err2 = secondPositioner.GetUpdateOptions(posOption);
       
   210 	AssertTrueL(err2 == KErrNone, KGetUpdateOptionsErr, err2);
       
   211 	posOption.SetMaxUpdateAge(0);
       
   212 	err2 = secondPositioner.SetUpdateOptions(posOption);
       
   213 	AssertTrueL(err2 == KErrNone, KSetUpdateOptionsErr, err2);
       
   214 
       
   215 	// perform initial request by first positioner
       
   216 	err = PerformSyncRequest(KService, &posInfo1);
       
   217 	if (err != KErrNone)
       
   218 		{
       
   219 		INFO_PRINTF2(_L("Error on getting fix = %d"), err);
       
   220 		LogErrorAndLeaveL(KError1);
       
   221 		}
       
   222 
       
   223 	TRequestStatus stat;
       
   224 	TPosition myPos1 = TPosition();
       
   225 	TPosition myPos2 = TPosition();
       
   226 	// perform two requests, by two different positioners
       
   227 	if (aSimultaneousRequest)
       
   228 		{
       
   229 		// position should be the same only if request times are equal
       
   230 		TInt loopIteration = 0;
       
   231 		do	
       
   232 			{
       
   233 			PerformSimultaneousRequestsL(secondPositioner,
       
   234 					posInfo1, posInfo2, KErrNone);
       
   235 			posInfo2.GetPosition(myPos2);
       
   236 			posInfo1.GetPosition(myPos1);
       
   237 			if (loopIteration > KMaxNumberOfTests)
       
   238 				{
       
   239 				LogErrorAndLeaveL(KError2);
       
   240 				}
       
   241 			loopIteration++;
       
   242 			}
       
   243 		while (myPos1.Time() != myPos2.Time());
       
   244 		}
       
   245 	else
       
   246 		{
       
   247 		PerformStaggeredRequestsL(secondPositioner, aIsNmea, aSwitchDataMode,
       
   248 					aCommonDataSet, posInfo1, posInfo2);
       
   249 		posInfo2.GetPosition(myPos2);
       
   250 		posInfo1.GetPosition(myPos1);
       
   251 		}
       
   252 
       
   253 	CheckPositionDataL(aIsNmea, aSimultaneousRequest, myPos1, myPos2);
       
   254 
       
   255 	CleanupStack::PopAndDestroy(&secondPositioner);
       
   256 	}
       
   257 
       
   258 void CT_LbsSimulationPsyPosTp500::TestMultipleClientChangeDataModeL(
       
   259 		const TBool aIsNmea, const TBool aCommonDataSet,
       
   260 		const TBool aSwitchDataMode)
       
   261 	{
       
   262 	// Set data file
       
   263 	if (!aIsNmea)
       
   264 		{
       
   265 		SetSimDataFileL(KSimulationSource);
       
   266 		}
       
   267 	else
       
   268 		{
       
   269 		SetSimDataFileL(KMagellanTracker);
       
   270 		}
       
   271 
       
   272 	SetCommonDataSetL(aCommonDataSet); // set common data mode
       
   273 
       
   274 	RPositioner secondPositioner;
       
   275 
       
   276 	TPositionInfo posInfo1;
       
   277 	TPositionInfo posInfo2;
       
   278 
       
   279 	OpenPositionersLC(secondPositioner);
       
   280 
       
   281 	PerformStaggeredRequestsL(secondPositioner, aIsNmea, aSwitchDataMode,
       
   282 			aCommonDataSet, posInfo1, posInfo2);
       
   283 
       
   284 	TPosition myPos1 = TPosition();
       
   285 	TPosition myPos2 = TPosition();
       
   286 	
       
   287 	posInfo2.GetPosition(myPos2);
       
   288 	posInfo1.GetPosition(myPos1);
       
   289 
       
   290 	//check output data
       
   291 	CheckPositionDataL(aIsNmea, !aCommonDataSet, myPos1, myPos2);
       
   292 
       
   293 	CleanupStack::PopAndDestroy(&secondPositioner);
       
   294 	}
       
   295 
       
   296 void CT_LbsSimulationPsyPosTp500::TestMultipleClientPartialFixL()
       
   297 	{
       
   298 	_LIT(KErrorPartialUpdate1, "Error, Returned Fix is not complete.");
       
   299 	_LIT(KErrorPartialUpdate2, "Error, Returned Fix is complete.");
       
   300 #ifdef __WINS__
       
   301 	_LIT(KNmeaDataFile, "z:\\system\\test\\testdata\\tp300longfile.nme");
       
   302 #else
       
   303 	_LIT(KNmeaDataFile, "c:\\system\\test\\testdata\\tp300longfile.nme");
       
   304 #endif
       
   305 
       
   306 	//Setting NMEA data file, and performing a request.
       
   307 	SetSimDataFileL(KNmeaDataFile);
       
   308 
       
   309 	RPositioner secondPositioner;
       
   310 
       
   311 	OpenPositionersLC(secondPositioner);
       
   312 
       
   313 	SetPartialUpdateL(ETrue, iPositioner);
       
   314 
       
   315 	TRequestStatus stat;
       
   316 	TPositionInfo posInfo1;
       
   317 	TPositionInfo posInfo2;
       
   318 	//perform request for a full fix
       
   319 	PerformSimultaneousRequestsL(secondPositioner, posInfo1, posInfo2, KPositionPartialUpdate);
       
   320 
       
   321 	//The fix should not be partial.
       
   322 	if (IsPositionInfoPartial(posInfo2))
       
   323 		{
       
   324 		LogErrorAndLeaveL(KErrorPartialUpdate1);
       
   325 		}
       
   326 	//The fix should be partial.
       
   327 	if (!IsPositionInfoPartial(posInfo1))
       
   328 		{
       
   329 		LogErrorAndLeaveL(KErrorPartialUpdate2);
       
   330 		}
       
   331 
       
   332 	CleanupStack::PopAndDestroy(&secondPositioner);
       
   333 	}
       
   334 
       
   335 void CT_LbsSimulationPsyPosTp500::TestNmeaPartialFixL()
       
   336 	{
       
   337 	_LIT(KPartialRequest, "Sending NMEA Partial Request.");
       
   338 	_LIT(KFixReturned, "Complete Fix Returned.");
       
   339 	_LIT(KError, "Unexpected Error occurred: %d");
       
   340 	_LIT(KModuleStatusError, "Error when requesting Module Status: %d");
       
   341 	_LIT(KErrorPartialUpdate, "Error, Returned Fix is not complete.");
       
   342 	_LIT(KQualityError, "Module Data Quality To Low : %d (See: TDataQualityStatus values)");
       
   343 #ifdef __WINS__
       
   344 	_LIT(KNmeaDataFile, "z:\\system\\test\\testdata\\fix10magellangps315.nme");
       
   345 #else
       
   346 	_LIT(KNmeaDataFile, "c:\\system\\test\\testdata\\fix10magellangps315.nme");
       
   347 #endif
       
   348 
       
   349 	INFO_PRINTF1(KPartialRequest);
       
   350 
       
   351 	//Setting NMEA data file, and performing a request.
       
   352 	SetSimDataFileL(KNmeaDataFile);
       
   353 	INFO_PRINTF1(_L("Opening first positioner"));
       
   354 	User::LeaveIfError(OpenPositionerByName(iUidSimulationPsy));
       
   355 	SetPartialUpdateL(ETrue, iPositioner);
       
   356 	TPositionInfo posInfo;
       
   357 	TInt err = PerformSyncRequest(KService, &posInfo);
       
   358 	AssertTrueL(err == KErrNone, KError, err);
       
   359 
       
   360 	//The fix should not be partial.
       
   361 	if (IsPositionInfoPartial(posInfo))
       
   362 		{
       
   363 		LogErrorAndLeaveL(KErrorPartialUpdate);
       
   364 		}
       
   365 
       
   366 	//Get Module Status.
       
   367 	TPositionModuleStatus moduleStatus;
       
   368 	err = iPosServer.GetModuleStatus(moduleStatus, iUidSimulationPsy);
       
   369 	AssertTrueL(err == KErrNone, KModuleStatusError, err);
       
   370 
       
   371 	//Check DataQualityStatus, should be EDataQualityNormal 
       
   372 	//but for partial updates it is EDataQualityPartial.
       
   373 	AssertTrueL(moduleStatus.DataQualityStatus()
       
   374 			== TPositionModuleStatus::EDataQualityNormal, KQualityError,
       
   375 			moduleStatus.DataQualityStatus());
       
   376 
       
   377 	INFO_PRINTF1(KFixReturned);
       
   378 	}
       
   379 
       
   380 /*
       
   381  * The method sets new Data Mode value and stores it in central repository.
       
   382  * @param aCommonDataSet value to be set in central repository.
       
   383  */
       
   384 void CT_LbsSimulationPsyPosTp500::SetCommonDataSetL(const TBool aCommonDataSet) const
       
   385 	{
       
   386 	TInt commonDataSet;
       
   387 	if (aCommonDataSet)
       
   388 		{
       
   389 		commonDataSet = 1; // Common Data Set is enabled
       
   390 		}
       
   391 	else
       
   392 		{
       
   393 		commonDataSet = 0;
       
   394 		}
       
   395 	// Set Common Data Set behaviour in the Central Repository
       
   396 	CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY);
       
   397 	User::LeaveIfError(repository-> Set(KCRKeySimPSYCommonDataSet,
       
   398 			commonDataSet));
       
   399 	CleanupStack::PopAndDestroy(repository);
       
   400 	}
       
   401 
       
   402 /*
       
   403  * The method gets Data Mote value from central repository.
       
   404  * @param aCommonDataSet value read from central repository.
       
   405  */
       
   406 void CT_LbsSimulationPsyPosTp500::GetCommonDataSetL(TInt& aTrpMode) const
       
   407 	{
       
   408 	// Get the Common Data Set setting from Central Repository
       
   409 	CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY);
       
   410 	User::LeaveIfError(repository->Get(KCRKeySimPSYCommonDataSet, aTrpMode));
       
   411 	CleanupStack::PopAndDestroy(repository);
       
   412 	}
       
   413 
       
   414 /*
       
   415  * The method opens two positioners. First (iPositioner) one is taken from the base class. 
       
   416  * They are expected to be constructed but not opened.
       
   417  * @param aPositioner additional positioner which needs to be opened. Requestor is set for it.
       
   418  * 			CleanupClosePushL() is used to push aPositioner onto the cleanup stack.
       
   419  */
       
   420 void CT_LbsSimulationPsyPosTp500::OpenPositionersLC(RPositioner& aPositioner)
       
   421 	{
       
   422 	TInt err;
       
   423 
       
   424 	INFO_PRINTF1(_L("Opening first positioner"));
       
   425 	User::LeaveIfError(OpenPositionerByName(iUidSimulationPsy));
       
   426 
       
   427 	INFO_PRINTF1(_L("Opening second positioner"));
       
   428 	err = aPositioner.Open(iPosServer, iUidSimulationPsy);
       
   429 	User::LeaveIfError(err);
       
   430 	CleanupClosePushL(aPositioner);
       
   431 	err = aPositioner.SetRequestor(CRequestor::ERequestorService,
       
   432 			CRequestor::EFormatApplication, KService);
       
   433 	if (err != KErrNone)
       
   434 		{
       
   435 		_LIT(KErrRequestor, "Error when setting requestor.");
       
   436 		LogErrorAndLeaveL(KErrRequestor, err);
       
   437 		}
       
   438 	}
       
   439 
       
   440 /*
       
   441  * Allows Positioner to accept partial update. 
       
   442  * @param aPartial ETrue for partial updates allowed.
       
   443  * @param aPositioner positioner to accept partial update.
       
   444  */
       
   445 void CT_LbsSimulationPsyPosTp500::SetPartialUpdateL(TBool aPartial,
       
   446 		RPositioner& aPositioner)
       
   447 	{
       
   448 	_LIT(KGetUpdateOptionsErr, "Error %d when getting update options.");
       
   449 	_LIT(KSetUpdateOptionsErr, "Error %d when setting update options.");
       
   450 
       
   451 	TPositionUpdateOptions posOption;
       
   452 	TInt err = aPositioner.GetUpdateOptions(posOption);
       
   453 	AssertTrueL(err == KErrNone, KGetUpdateOptionsErr, err);
       
   454 	posOption.SetAcceptPartialUpdates(aPartial);
       
   455 	err = aPositioner.SetUpdateOptions(posOption);
       
   456 	AssertTrueL(err == KErrNone, KSetUpdateOptionsErr, err);
       
   457 	}
       
   458 
       
   459 /*
       
   460  * The method checks whether the position is a partial fix.
       
   461  * @param aPosInfo position information.
       
   462  * @return ETrue for partial position info. Otherwise EFalse.
       
   463  */
       
   464 TBool CT_LbsSimulationPsyPosTp500::IsPositionInfoPartial(
       
   465 		const TPositionInfo& aPosInfo)
       
   466 	{
       
   467 	TBool partialFix = EFalse;
       
   468 	TPosition pos;
       
   469 	aPosInfo.GetPosition(pos);
       
   470 
       
   471 	if (Math::IsNaN(pos.Longitude()))
       
   472 		{
       
   473 		partialFix = ETrue;
       
   474 		}
       
   475 	else if (Math::IsNaN(pos.Latitude()))
       
   476 		{
       
   477 		partialFix = ETrue;
       
   478 		}
       
   479 	else if (pos.Time().Int64() == 0)
       
   480 		{
       
   481 		partialFix = ETrue;
       
   482 		}
       
   483 	else if (Math::IsNaN(pos.Altitude()))
       
   484 		{
       
   485 		partialFix = ETrue;
       
   486 		}
       
   487 	else if (Math::IsNaN(pos.VerticalAccuracy()))
       
   488 		{
       
   489 		partialFix = ETrue;
       
   490 		}
       
   491 	else if (Math::IsNaN(pos.HorizontalAccuracy()))
       
   492 		{
       
   493 		partialFix = ETrue;
       
   494 		}
       
   495 
       
   496 	return partialFix;
       
   497 	}
       
   498 
       
   499 /*
       
   500  * The method waits required amount of time
       
   501  * @param aNmea if it is NMEA test or SPS.
       
   502  * @param aTime time to wait.
       
   503  */
       
   504 void CT_LbsSimulationPsyPosTp500::WaitForPositionChange(const TBool aNmea,
       
   505 		const TInt aTime)
       
   506 	{
       
   507 	User::After(aTime);
       
   508 	if (!aNmea) // sps file
       
   509 		{
       
   510 		
       
   511 		}
       
   512 	else // NMEA file
       
   513 		{
       
   514 		// Witold - czekamy na kod Lukasza
       
   515 		}
       
   516 	}
       
   517 
       
   518 /*
       
   519  * The method checks requested position data
       
   520  * @param aNmea is it NMEA test or SPS.
       
   521  * @param aSimultaneousRequest are two requests made at the same time
       
   522  * @param aPos1 first position request information.
       
   523  * @param aPos2 second position request information.
       
   524  */
       
   525 void CT_LbsSimulationPsyPosTp500::CheckPositionDataL(const TBool aNmea,
       
   526 		const TBool aSimultaneousRequest, const TPosition& aPos1, const TPosition& aPos2)
       
   527 	{
       
   528 	_LIT(KError1, "Error. Client 1 and Client 2 have different fixes.");
       
   529 	_LIT(KError2, "Error. Client 1 and Client 2 have the same fixes.");
       
   530 
       
   531 	//Note that in SPS mode if test machine meet performance difficulties these deviations may be to large.
       
   532 	TReal lonDeviation = Abs(aPos1.Longitude() - aPos2.Longitude());
       
   533 	TReal latDeviation = Abs(aPos1.Latitude() - aPos2.Latitude());
       
   534 
       
   535 	// SPS mode, two requests at the same time
       
   536 	if (aSimultaneousRequest && !aNmea)
       
   537 		{
       
   538 		// Witold - logs, to be removed before final check in
       
   539 		INFO_PRINTF3(_L("Deviations: Lon=%10.7f, Lat=%10.7f"), aPos1.Longitude(), aPos1.Latitude());
       
   540 		INFO_PRINTF3(_L("Deviations: Lon=%10.7f, Lat=%10.7f"), aPos2.Longitude(), aPos2.Latitude());
       
   541 		INFO_PRINTF1(_L("Check 1"));
       
   542 
       
   543 		if (lonDeviation > KMaxDev || latDeviation > KMaxDev)
       
   544 			{
       
   545 			INFO_PRINTF3(_L("Deviations: Lon=%10.7f, Lat=%10.7f"), lonDeviation, latDeviation);
       
   546 			LogErrorAndLeaveL(KError1);
       
   547 			}
       
   548 		}
       
   549 	// NMEA mode, two requests at the same time, no deviations
       
   550 	else if (aSimultaneousRequest && aNmea)
       
   551 		{
       
   552 		// Witold - logs, to be removed before final check in
       
   553 		INFO_PRINTF3(_L("Deviations: Lon=%10.7f, Lat=%10.7f"), aPos1.Longitude(), aPos1.Latitude());
       
   554 		INFO_PRINTF3(_L("Deviations: Lon=%10.7f, Lat=%10.7f"), aPos2.Longitude(), aPos2.Latitude());
       
   555 		INFO_PRINTF1(_L("Check 2"));
       
   556 
       
   557 		if (lonDeviation != 0 || latDeviation != 0)
       
   558 			{
       
   559 			INFO_PRINTF3(_L("Deviations: Lon=%10.7f, Lat=%10.7f"), aPos2.Latitude(), aPos1.Latitude());
       
   560 			LogErrorAndLeaveL(KError1);
       
   561 			}
       
   562 		}
       
   563 	// SPS mode, one request after another
       
   564 	else if (!aSimultaneousRequest && !aNmea) //SPS mode, insignificant deviations are unavoidable.
       
   565 		{
       
   566 		// Witold - logs, to be removed before final check in
       
   567 		INFO_PRINTF3(_L("Deviations: Lon=%10.7f, Lat=%10.7f"), aPos1.Longitude(), aPos1.Latitude());
       
   568 		INFO_PRINTF3(_L("Deviations: Lon=%10.7f, Lat=%10.7f"), aPos2.Longitude(), aPos2.Latitude());
       
   569 		INFO_PRINTF1(_L("Check 3"));
       
   570 	
       
   571 		if (aPos2.Longitude() <= aPos1.Longitude() && aPos2.Latitude()
       
   572 				<= aPos1.Latitude())
       
   573 			{
       
   574 			INFO_PRINTF3(_L("Deviations: Lon=%10.7f, Lat=%10.7f"), aPos2.Longitude(), aPos1.Longitude());
       
   575 			LogErrorAndLeaveL(KError2);
       
   576 			}
       
   577 		}
       
   578 	// NMEA mode, one request after another
       
   579 	else if (!aSimultaneousRequest && aNmea)
       
   580 		{
       
   581 		// Witold - logs, to be removed before final check in
       
   582 		INFO_PRINTF3(_L("Deviations: Lon=%10.7f, Lat=%10.7f"), aPos1.Longitude(), aPos1.Latitude());
       
   583 		INFO_PRINTF3(_L("Deviations: Lon=%10.7f, Lat=%10.7f"), aPos2.Longitude(), aPos2.Latitude());
       
   584 		INFO_PRINTF1(_L("Check 4"));
       
   585 
       
   586 		//NMEA mode 
       
   587 		if (lonDeviation == 0 || latDeviation == 0)
       
   588 			{
       
   589 			INFO_PRINTF3(_L("Deviations: Lon=%10.7f, Lat=%10.7f"), lonDeviation, latDeviation);
       
   590 			LogErrorAndLeaveL(KError2);
       
   591 			}
       
   592 		}
       
   593 	}
       
   594 
       
   595 /*
       
   596  * The method performs two staggered requests for two different positioners
       
   597  * @param aPositioner additional positioner sending request
       
   598  * @param aIsNmea ETrue if NMEA request
       
   599  * @param aSwitchDataMode ETrue if data mode needs to be changed
       
   600  * @param aCommonDataSet ETrue if data mode is Common
       
   601  * @param aPosInfo1 location fix for the first positioner
       
   602  * @param aPosInfo2 location second for the first positioner
       
   603  */
       
   604 void CT_LbsSimulationPsyPosTp500::PerformStaggeredRequestsL(RPositioner& aPositioner,
       
   605 			const TBool aIsNmea, const TBool aSwitchDataMode,
       
   606 			const TBool aCommonDataSet, TPositionInfo& aPosInfo1, TPositionInfo& aPosInfo2)
       
   607 	{
       
   608 	_LIT(KError1, "Error when requesting location");
       
   609 	TInt err;
       
   610 	//INFO_PRINTF1(_L("Request after time"));
       
   611 	err = PerformSyncRequest(KService, &aPosInfo1);
       
   612 	if (err != KErrNone)
       
   613 		{
       
   614 		INFO_PRINTF2(_L("Error on getting fix = %d"), err);
       
   615 		LogErrorAndLeaveL(KError1);
       
   616 		}
       
   617 
       
   618 	// change common data mode if required
       
   619 	if (aSwitchDataMode)
       
   620 		{
       
   621 		SetCommonDataSetL(!aCommonDataSet);
       
   622 		}
       
   623 
       
   624 	// wait for position to change
       
   625 	WaitForPositionChange(aIsNmea, KTimeToWaitBetweenRequests);
       
   626 
       
   627 	TRequestStatus stat;
       
   628 	aPositioner.NotifyPositionUpdate(aPosInfo2, stat);
       
   629 	User::WaitForRequest(stat);
       
   630 	if (err != KErrNone)
       
   631 		{
       
   632 		LogErrorAndLeaveL(KError1);
       
   633 		}
       
   634 	}
       
   635 
       
   636 /*
       
   637  * The method performs two simultaneous requests for two different positioners
       
   638  * @param aPositioner additional positioner sending request
       
   639  * @param aPosInfo1 location fix for the first positioner
       
   640  * @param aPosInfo2 location second for the first positioner
       
   641  * @param aError expected result of request action
       
   642  */
       
   643 void CT_LbsSimulationPsyPosTp500::PerformSimultaneousRequestsL(RPositioner& aPositioner,
       
   644 			TPositionInfo& aPosInfo1, TPositionInfo& aPosInfo2, const TInt aError)
       
   645 	{
       
   646 	_LIT(KError, "Error when requesting location");
       
   647 	TRequestStatus stat;
       
   648 	TInt err;
       
   649 	INFO_PRINTF1(_L("Request in progress"));
       
   650 	aPositioner.NotifyPositionUpdate(aPosInfo2, stat);
       
   651 	err = PerformSyncRequest(KService, &aPosInfo1);
       
   652 	if (err != aError)
       
   653 		{
       
   654 		INFO_PRINTF2(_L("Error on getting fix = %d"), err);
       
   655 		LogErrorAndLeaveL(KError);
       
   656 		}
       
   657 	User::WaitForRequest(stat);
       
   658 	}