|
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: Implemenation of CBlidLocation class which provides access to blid location and satellite information |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <lbs.h> |
|
22 #include <lbscommon.h> |
|
23 #include <inetprottextutils.h> |
|
24 #include <lbsposition.h> |
|
25 #include <lbssatellite.h> |
|
26 |
|
27 #include "CBlidLocation.h" |
|
28 #include "MBlidEngObserver.h" |
|
29 #include "blidengconsts.h" |
|
30 #include "blidcommonconsts.h" |
|
31 #include "Blid.hrh" |
|
32 #include "cblidmoduleinfoobserver.h" |
|
33 |
|
34 #ifdef _DEBUG |
|
35 #include "Debug.h" |
|
36 #endif |
|
37 |
|
38 // FORWARD DECLARATION |
|
39 TInt TimerCallBackFunctionL(TAny* aPtr); |
|
40 TInt SortCriteria(const TSatelliteData& aCurrent, const TSatelliteData& aNext); |
|
41 |
|
42 // ============================ MEMBER FUNCTIONS ============================== |
|
43 // ---------------------------------------------------------------------------- |
|
44 // CBlidLocation::CBlidLocation |
|
45 // C++ default constructor can NOT contain any code, that |
|
46 // might leave. |
|
47 // ---------------------------------------------------------------------------- |
|
48 // |
|
49 CBlidLocation::CBlidLocation(RPositionServer& aServer, CBlidEng& aEngine ) |
|
50 : CActive(EPriorityStandard) |
|
51 ,iServer( aServer ), iRequesting( EFalse ), |
|
52 iOnlineMode( EFalse ),iIsDistance(ETrue), |
|
53 iDistanceTravelled(0),iIsTripStart(EFalse), |
|
54 iIsTripNotStart(ETrue),iIsTripClear(EFalse), |
|
55 iIsTripReset(EFalse),iEngine(aEngine) |
|
56 |
|
57 { |
|
58 CActiveScheduler::Add( this ); |
|
59 } |
|
60 |
|
61 |
|
62 // ---------------------------------------------------------------------------- |
|
63 // CBlidLocation::ConstructL |
|
64 // Symbian 2nd phase constructor can leave. |
|
65 // ---------------------------------------------------------------------------- |
|
66 // |
|
67 void CBlidLocation::ConstructL( ) |
|
68 { |
|
69 iSatelliteCapability = IsSatelliteCapabilityL(); |
|
70 //User::LeaveIfError(iPositioner.Open( iServer )); |
|
71 // get the number of modules |
|
72 GetModuleInfoNotificationL(); |
|
73 // and registered for notification |
|
74 iModuleInfoObserv = CBlidModuleinfoObserver::NewL( iServer, *this ); |
|
75 iModuleInfoObserv->StartNotification(); |
|
76 |
|
77 //initialize iSpeedAverage |
|
78 TRealX temp; |
|
79 temp.SetNaN(); |
|
80 iSpeedAverage = temp; |
|
81 iHeading = 0; |
|
82 iGPSDataAvailable = EFalse; |
|
83 iTripAverageSpeed = 0.0; |
|
84 iTripMaxSpeed = 0.0; |
|
85 iIsPreviousPositionUpdated = EFalse; |
|
86 iWaitingGpsData = ETrue; |
|
87 iIsDistanceTravelled = ETrue; |
|
88 iRegisteredViewId = EBlidMainView; |
|
89 iUpdateReceived = EFalse; |
|
90 iDeviceStatus = EDeviceUnderConnection; |
|
91 } |
|
92 |
|
93 // ---------------------------------------------------------------------------- |
|
94 // CBlidLocation::NewL |
|
95 // Two-phased constructor. |
|
96 // ---------------------------------------------------------------------------- |
|
97 // |
|
98 CBlidLocation* CBlidLocation::NewL( RPositionServer& aServer, CBlidEng& aEngine ) |
|
99 { |
|
100 CBlidLocation* self = new( ELeave ) CBlidLocation(aServer, aEngine); |
|
101 CleanupStack::PushL( self ); |
|
102 self->ConstructL(); |
|
103 CleanupStack::Pop( self ); //self |
|
104 return self; |
|
105 } |
|
106 |
|
107 // ---------------------------------------------------------------------------- |
|
108 // CBlidLocation::~CBlidLocation |
|
109 // ---------------------------------------------------------------------------- |
|
110 // |
|
111 CBlidLocation::~CBlidLocation() |
|
112 { |
|
113 Cancel(); |
|
114 iPositioner.Close(); |
|
115 iSpeedArray.Close(); |
|
116 if(iTimer) |
|
117 { |
|
118 delete iTimer; |
|
119 iTimer = NULL; |
|
120 } |
|
121 iModuleInfoArray.Reset(); |
|
122 delete iModuleInfoObserv; |
|
123 iSortedSatData.Reset(); |
|
124 } |
|
125 |
|
126 // ---------------------------------------------------------------------------- |
|
127 // CBlidLocation::SetObserver |
|
128 // ---------------------------------------------------------------------------- |
|
129 // |
|
130 void CBlidLocation::SetObserver(MBlidEngObserver& aObserver, TInt aViewId) |
|
131 { |
|
132 iObserver = &aObserver; |
|
133 iRegisteredViewId = aViewId; |
|
134 // added to fix TSW error |
|
135 iLastGoodFixTime.UniversalTime(); |
|
136 |
|
137 if(iUpdateReceived) |
|
138 { |
|
139 SetUpdateOptions(); |
|
140 } |
|
141 } |
|
142 |
|
143 // ---------------------------------------------------------------------------- |
|
144 // CBlidLocation::RemoveModelObserver |
|
145 // ---------------------------------------------------------------------------- |
|
146 // |
|
147 void CBlidLocation::RemoveModelObserver() |
|
148 { |
|
149 iObserver = NULL; |
|
150 } |
|
151 |
|
152 // ---------------------------------------------------------------------------- |
|
153 // CBlidLocation::InitialLocationRequestL |
|
154 // ---------------------------------------------------------------------------- |
|
155 // |
|
156 void CBlidLocation::InitialLocationRequestL( const TDesC& aSrvName ) |
|
157 { |
|
158 User::LeaveIfError(iPositioner.Open( iServer )); |
|
159 |
|
160 User::LeaveIfError(iPositioner.SetRequestor( |
|
161 CRequestor::ERequestorService, |
|
162 CRequestor::EFormatApplication, |
|
163 aSrvName )); |
|
164 SetUpdateOptions(); |
|
165 iRequesting = ETrue; |
|
166 } |
|
167 |
|
168 // ---------------------------------------------------------------------------- |
|
169 // CBlidLocation::CurrentPosition |
|
170 // ---------------------------------------------------------------------------- |
|
171 // |
|
172 TPosition& CBlidLocation::GetCurrentPosition() |
|
173 { |
|
174 return iPosition; |
|
175 } |
|
176 |
|
177 // ---------------------------------------------------------------------------- |
|
178 // CBlidLocation::IsSatelliteCapability |
|
179 // ---------------------------------------------------------------------------- |
|
180 // |
|
181 TBool CBlidLocation::IsSatelliteCapabilityL() |
|
182 { |
|
183 TUint count = 0; |
|
184 User::LeaveIfError( iServer.GetNumModules(count) ); |
|
185 TPositionModuleInfo moduleInfo; |
|
186 |
|
187 for( TUint i = 0; i < count; i++ ) |
|
188 { |
|
189 User::LeaveIfError( iServer.GetModuleInfoByIndex( i, moduleInfo ) ); |
|
190 if ( moduleInfo.Capabilities() & |
|
191 TPositionModuleInfo::ECapabilitySatellite ) |
|
192 { |
|
193 return ETrue; |
|
194 } |
|
195 } |
|
196 |
|
197 return EFalse; |
|
198 } |
|
199 |
|
200 // ---------------------------------------------------------------------------- |
|
201 // CBlidLocation::GetCourseInfo |
|
202 // ---------------------------------------------------------------------------- |
|
203 // |
|
204 TCourse& CBlidLocation::GetCourse() |
|
205 { |
|
206 return iCourse; |
|
207 } |
|
208 |
|
209 // ---------------------------------------------------------------------------- |
|
210 // CBlidLocation::CancelRequest |
|
211 // ---------------------------------------------------------------------------- |
|
212 // |
|
213 void CBlidLocation::CancelRequest() |
|
214 { |
|
215 Cancel(); |
|
216 } |
|
217 |
|
218 // ---------------------------------------------------------------------------- |
|
219 // CBlidLocation::StopRequesting |
|
220 // ---------------------------------------------------------------------------- |
|
221 // |
|
222 void CBlidLocation::StopRequesting() |
|
223 { |
|
224 iOnlineMode = EFalse; |
|
225 iRequesting = EFalse; |
|
226 } |
|
227 |
|
228 |
|
229 // ---------------------------------------------------------------------------- |
|
230 // CBlidLocation::StartRequesting |
|
231 // ---------------------------------------------------------------------------- |
|
232 // |
|
233 void CBlidLocation::StartRequesting() |
|
234 { |
|
235 if ( !IsActive() ) |
|
236 { |
|
237 SetUpdateOptions(); |
|
238 } |
|
239 iRequesting = ETrue; |
|
240 } |
|
241 |
|
242 // ---------------------------------------------------------------------------- |
|
243 // CBlidLocation::IsOnline |
|
244 // ---------------------------------------------------------------------------- |
|
245 // |
|
246 TBool CBlidLocation::IsOnline() |
|
247 { |
|
248 return iOnlineMode; |
|
249 } |
|
250 |
|
251 // ---------------------------------------------------------------------------- |
|
252 // CBlidLocation::SatelliteCapability |
|
253 // ---------------------------------------------------------------------------- |
|
254 // |
|
255 TBool CBlidLocation::SatelliteCapability() |
|
256 { |
|
257 return iSatelliteCapability; |
|
258 } |
|
259 |
|
260 // ---------------------------------------------------------------------------- |
|
261 // CBlidLocation::SpeedAverage |
|
262 // ---------------------------------------------------------------------------- |
|
263 // |
|
264 TReal CBlidLocation::SpeedAverage() |
|
265 { |
|
266 return iSpeedAverage; |
|
267 } |
|
268 |
|
269 // ---------------------------------------------------------------------------- |
|
270 // CBlidLocation::MaxSpeed |
|
271 // ---------------------------------------------------------------------------- |
|
272 // |
|
273 TReal CBlidLocation::MaxSpeed() |
|
274 { |
|
275 return iMaxSpeed; |
|
276 } |
|
277 |
|
278 // ---------------------------------------------------------------------------- |
|
279 // CBlidLocation::WaitingGPSData |
|
280 // ---------------------------------------------------------------------------- |
|
281 // |
|
282 TBool CBlidLocation::WaitingGPSData() |
|
283 { |
|
284 return iWaitingGpsData; |
|
285 } |
|
286 |
|
287 // ---------------------------------------------------------------------------- |
|
288 // CBlidLocation::IsGPSDeviceConnected |
|
289 // ---------------------------------------------------------------------------- |
|
290 // |
|
291 TBool CBlidLocation::IsGPSDeviceConnected() |
|
292 { |
|
293 return (iDeviceStatus == EDeviceConnected); |
|
294 } |
|
295 |
|
296 // ---------------------------------------------------------------------------- |
|
297 // CBlidLocation::RunL |
|
298 // ---------------------------------------------------------------------------- |
|
299 // |
|
300 void CBlidLocation::RunL() |
|
301 { |
|
302 iPosStatus = iStatus; |
|
303 |
|
304 iDeviceStatus = EDeviceConnected; |
|
305 SortSatelliteDataL(); |
|
306 |
|
307 switch (iStatus.Int()) |
|
308 { |
|
309 //case KPositionPartialUpdate: |
|
310 case KErrNone: // Success |
|
311 { |
|
312 iOnlineMode = ETrue; |
|
313 iUpdateReceived = ETrue; |
|
314 iGPSDataAvailable = ETrue; |
|
315 iPositionInfo.GetPosition(iPosition); |
|
316 iPositionInfo.GetCourse(iCourse); |
|
317 iLastGoodFixTime.UniversalTime(); |
|
318 |
|
319 CalculateCourse(); |
|
320 |
|
321 if (iIsTripStart) |
|
322 { |
|
323 if (!iIsPreviousPositionUpdated) |
|
324 { |
|
325 iIsPreviousPositionUpdated = ETrue; |
|
326 iPrevPosition = GetCurrentPosition(); |
|
327 } |
|
328 UpdateTripData(); |
|
329 } |
|
330 if (iObserver) |
|
331 { |
|
332 iObserver->NotifyL(iOnlineMode); |
|
333 } |
|
334 if (iRequesting) |
|
335 { |
|
336 //DEBUG("KErrNone : NotifyPositionUpdate"); |
|
337 iPositioner.NotifyPositionUpdate(iPositionInfo, iStatus); |
|
338 SetActive(); |
|
339 } |
|
340 break; |
|
341 } |
|
342 case KErrAccessDenied: |
|
343 /* |
|
344 Happens if we don't specify requestor information. |
|
345 This condition should not be encountered. |
|
346 */ |
|
347 { |
|
348 iPositionInfo.ClearSatellitesInView(); |
|
349 iRequesting = EFalse; |
|
350 User::Leave(KErrAccessDenied); |
|
351 break; |
|
352 } |
|
353 case KErrCancel: // Postion update request cancelled |
|
354 { |
|
355 // We canceled the request so do nothing |
|
356 iPositionInfo.ClearSatellitesInView(); |
|
357 break; |
|
358 } |
|
359 case KPositionPartialUpdate: // Incomplete position information |
|
360 { |
|
361 |
|
362 TTime now; |
|
363 now.UniversalTime(); |
|
364 TTimeIntervalSeconds secondsSinceLastGoodFix; |
|
365 now.SecondsFrom(iLastGoodFixTime, secondsSinceLastGoodFix); |
|
366 if (secondsSinceLastGoodFix.Int() > 15) |
|
367 { |
|
368 iLastGoodFixTime.UniversalTime(); |
|
369 if (iObserver) |
|
370 { |
|
371 iObserver->NotifyErrorL(KErrTimedOut); |
|
372 } |
|
373 } |
|
374 |
|
375 else |
|
376 { |
|
377 iLastGoodFixTime.UniversalTime(); |
|
378 } |
|
379 // end of addition for TSW error |
|
380 |
|
381 iGPSDataAvailable = EFalse; |
|
382 iUpdateReceived = ETrue; |
|
383 |
|
384 // All cases are errors and hence go to offline mode |
|
385 iOnlineMode = EFalse; |
|
386 if (iObserver) |
|
387 { |
|
388 iObserver->NotifyErrorL(iStatus.Int()); |
|
389 } |
|
390 if (iRequesting) |
|
391 { |
|
392 iPositioner.NotifyPositionUpdate(iPositionInfo, iStatus); |
|
393 SetActive(); |
|
394 } |
|
395 break; |
|
396 } |
|
397 |
|
398 case KErrTimedOut: // Position update timed out |
|
399 case KPositionQualityLoss: //GPS not connected |
|
400 { |
|
401 iPositionInfo.ClearSatellitesInView(); |
|
402 iUpdateReceived = ETrue; |
|
403 iGPSDataAvailable = EFalse; |
|
404 if (iIsTripStart && !iIsTripClear) |
|
405 { |
|
406 iTripGPSDataLost = ETrue; |
|
407 } |
|
408 // Leaving break is intentional |
|
409 } |
|
410 //-fallthrough |
|
411 case KErrNotFound: // No PSY selected. |
|
412 case KErrUnknown: // This will be returned by MLFW |
|
413 case KErrArgument: |
|
414 |
|
415 /* |
|
416 PSY does not support the information type specified |
|
417 by BLID. |
|
418 */ |
|
419 default: |
|
420 { |
|
421 iDeviceStatus = EDeviceNotFound; |
|
422 iWaitingGpsData = EFalse; |
|
423 if (iObserver) |
|
424 { |
|
425 iObserver->NotifyErrorL(KErrNotFound); |
|
426 } |
|
427 if (iRequesting) |
|
428 { |
|
429 iPositioner.NotifyPositionUpdate(iPositionInfo, iStatus); |
|
430 SetActive(); |
|
431 } |
|
432 } |
|
433 break; |
|
434 } |
|
435 /*if( iStatus.Int() != KErrCancel ) |
|
436 { |
|
437 //DEBUG("RUNL : SetUpdateOptions"); |
|
438 SetUpdateOptions(); |
|
439 }*/ |
|
440 if (iStatus.Int() != KPositionPartialUpdate) |
|
441 { |
|
442 iWaitingGpsData = CheckIfWaitingGPSData(); |
|
443 } |
|
444 } |
|
445 |
|
446 // ---------------------------------------------------------------------------- |
|
447 // CBlidLocation::SetUpdateOptions |
|
448 // ---------------------------------------------------------------------------- |
|
449 // |
|
450 void CBlidLocation::SetUpdateOptions() |
|
451 { |
|
452 if(IsActive()) |
|
453 { |
|
454 Cancel(); |
|
455 } |
|
456 // update interval |
|
457 TInt intervalTime = KMidIntervalTime; |
|
458 |
|
459 if(iEngine.AppMode() == CBlidEng::EAppBackground) // If application is in background mode |
|
460 { |
|
461 TRAP_IGNORE(UpdateIntervalL( KMaxIntervalTime )); |
|
462 if ( iRequesting ) |
|
463 { |
|
464 iPositioner.NotifyPositionUpdate( iPositionInfo, iStatus ); |
|
465 SetActive(); |
|
466 } |
|
467 return; |
|
468 } |
|
469 |
|
470 switch(iRegisteredViewId) |
|
471 { |
|
472 case EBlidNavigationView: |
|
473 { |
|
474 TReal32 distance; |
|
475 TInt retVal; |
|
476 retVal = iEngine.GetDistanceToDestination(distance); |
|
477 if(retVal == KErrNone) |
|
478 { |
|
479 if(distance <= KBlidHundredMeters) |
|
480 { |
|
481 intervalTime = KShortIntervalTime; |
|
482 } |
|
483 else if(distance > KBlidHundredMeters && |
|
484 distance < KBlidOneKilometer) |
|
485 { |
|
486 intervalTime = KMidIntervalTime; |
|
487 } |
|
488 else |
|
489 { |
|
490 intervalTime = KMaxIntervalTime; |
|
491 } |
|
492 } |
|
493 else |
|
494 { |
|
495 intervalTime = KShortIntervalTime; |
|
496 } |
|
497 break; |
|
498 } |
|
499 case EBlidTripMeterView: |
|
500 { |
|
501 if(iDistanceTravelled < KBlidHundredMeters) |
|
502 { |
|
503 intervalTime = KShortIntervalTime; |
|
504 } |
|
505 else if(iDistanceTravelled > KBlidHundredMeters && |
|
506 iDistanceTravelled < KBlidOneKilometer) |
|
507 { |
|
508 intervalTime = KMidIntervalTime; |
|
509 } |
|
510 else |
|
511 { |
|
512 intervalTime = KMaxIntervalTime; |
|
513 } |
|
514 break; |
|
515 } |
|
516 case EBlidMainView: |
|
517 default: |
|
518 { |
|
519 intervalTime = KMidIntervalTime; |
|
520 break; |
|
521 } |
|
522 } |
|
523 TRAP_IGNORE(UpdateIntervalL( intervalTime )); |
|
524 if ( iRequesting ) |
|
525 { |
|
526 iPositioner.NotifyPositionUpdate( iPositionInfo, iStatus ); |
|
527 SetActive(); |
|
528 } |
|
529 } |
|
530 |
|
531 // ---------------------------------------------------------------------------- |
|
532 // CBlidLocation::DoCancel |
|
533 // ---------------------------------------------------------------------------- |
|
534 // |
|
535 void CBlidLocation::DoCancel() |
|
536 { |
|
537 iPositioner.CancelRequest( EPositionerNotifyPositionUpdate ); |
|
538 } |
|
539 |
|
540 // ---------------------------------------------------------------------------- |
|
541 // CBlidLocation::RunError |
|
542 // ---------------------------------------------------------------------------- |
|
543 // |
|
544 TInt CBlidLocation::RunError(TInt aError) |
|
545 { |
|
546 if ( iObserver && aError != KBlidLeaveExit ) |
|
547 { |
|
548 TRAPD(error,iObserver->NotifyErrorL( aError )); |
|
549 if(error != KErrNone) |
|
550 { |
|
551 return error; |
|
552 } |
|
553 } |
|
554 return aError; |
|
555 } |
|
556 |
|
557 // ---------------------------------------------------------------------------- |
|
558 // CBlidLocation::UpdateIntervalL |
|
559 // ---------------------------------------------------------------------------- |
|
560 // |
|
561 void CBlidLocation::UpdateIntervalL( const TInt aIntervalTime ) |
|
562 { |
|
563 iCurrentUpdateInterval = aIntervalTime; |
|
564 TPositionUpdateOptions updateOptions; |
|
565 updateOptions.SetUpdateInterval(TTimeIntervalMicroSeconds(aIntervalTime)); |
|
566 updateOptions.SetAcceptPartialUpdates( ETrue ); |
|
567 if(iUpdateReceived) |
|
568 { |
|
569 updateOptions.SetUpdateTimeOut( TTimeIntervalMicroSeconds(KUpdateIntervalTimeOut)); |
|
570 } |
|
571 else |
|
572 { |
|
573 updateOptions.SetUpdateTimeOut( TTimeIntervalMicroSeconds(KStartUpdateIntervalTimeOut)); |
|
574 } |
|
575 User::LeaveIfError( iPositioner.SetUpdateOptions(updateOptions) ); |
|
576 } |
|
577 |
|
578 |
|
579 // ---------------------------------------------------------------------------- |
|
580 // CBlidLocation::GetCurrentUpdateInterval |
|
581 // ---------------------------------------------------------------------------- |
|
582 // |
|
583 void CBlidLocation:: GetCurrentUpdateInterval(TInt& aInterval) |
|
584 { |
|
585 aInterval = iCurrentUpdateInterval; |
|
586 } |
|
587 |
|
588 // ---------------------------------------------------------------------------- |
|
589 // CBlidLocation::GetPositionInfoStatus |
|
590 // ---------------------------------------------------------------------------- |
|
591 // |
|
592 TInt CBlidLocation::GetPositionInfoStatus() |
|
593 { |
|
594 return iPosStatus.Int(); |
|
595 } |
|
596 |
|
597 // ---------------------------------------------------------------------------- |
|
598 // CBlidLocation::CheckIfWaitingGPSData |
|
599 // ---------------------------------------------------------------------------- |
|
600 // |
|
601 TBool CBlidLocation::CheckIfWaitingGPSData() |
|
602 { |
|
603 if(iDeviceStatus == EDeviceUnderConnection) |
|
604 { |
|
605 return ETrue; |
|
606 } |
|
607 |
|
608 // If none of the above then check satellite status |
|
609 TInt num = iPositionInfo.NumSatellitesInView(); |
|
610 if(num > 0) |
|
611 { |
|
612 return ETrue; |
|
613 } |
|
614 return EFalse; |
|
615 } |
|
616 |
|
617 // ---------------------------------------------------------------------------- |
|
618 // CBlidLocation::GetRegisteredViewId |
|
619 // ---------------------------------------------------------------------------- |
|
620 // |
|
621 TInt CBlidLocation::GetRegisteredViewId() |
|
622 { |
|
623 return iRegisteredViewId; |
|
624 } |
|
625 |
|
626 // ---------------------------------------------------------------------------- |
|
627 // CBlidLocation::GetModuleInfoStatus |
|
628 // ---------------------------------------------------------------------------- |
|
629 // |
|
630 void CBlidLocation::GetModuleInfoStatus(TPositionModuleStatusBase& aPosModuleStatus) |
|
631 { |
|
632 // This function scan through the all satellite and selected PSY |
|
633 // and check the status of those PSY's if those are in Device err state. |
|
634 // |
|
635 TUint numberOfModules; |
|
636 TPositionModuleInfo moduleInfo; |
|
637 numberOfModules = iModuleInfoArray.Count(); |
|
638 |
|
639 if( numberOfModules > 0) |
|
640 { |
|
641 for( TInt i = 0; i < numberOfModules; i++ ) |
|
642 { |
|
643 moduleInfo = iModuleInfoArray[i]; |
|
644 if ( (moduleInfo.Capabilities() & |
|
645 TPositionModuleInfo::ECapabilitySatellite ) && |
|
646 moduleInfo.IsAvailable()) |
|
647 { |
|
648 TPositionModuleId moduleId = moduleInfo.ModuleId(); |
|
649 iServer.GetModuleStatus(aPosModuleStatus, moduleId); |
|
650 |
|
651 TPositionModuleStatus lPosModuleStatus; |
|
652 iServer.GetModuleStatus(lPosModuleStatus, moduleId); |
|
653 TInt resulterr = lPosModuleStatus.DeviceStatus(); |
|
654 |
|
655 if( (resulterr == TPositionModuleStatus::EDeviceError ) || |
|
656 (resulterr == TPositionModuleStatus::EDeviceInactive ) || |
|
657 (resulterr == TPositionModuleStatus::EDeviceStandBy ) ) |
|
658 { |
|
659 continue; |
|
660 } |
|
661 else |
|
662 { |
|
663 break; |
|
664 } |
|
665 } |
|
666 } |
|
667 } |
|
668 } |
|
669 |
|
670 // ---------------------------------------------------------------------------- |
|
671 // CBlidLocation::GetNumOfSatellitesL |
|
672 // ---------------------------------------------------------------------------- |
|
673 // |
|
674 void CBlidLocation::GetNumOfSatellitesL(TInt& aNumSatellites) |
|
675 { |
|
676 TSatelliteData tempSatelliteData; |
|
677 TPosition CurrentPosition; |
|
678 TInt totalStrength = 0; |
|
679 TInt noOfSatUsed = iPositionInfo.NumSatellitesUsed(); |
|
680 TInt noOfSatInView = iPositionInfo.NumSatellitesInView(); |
|
681 iPositionInfo.GetPosition( CurrentPosition ); |
|
682 TBool isLat = Math::IsNaN( CurrentPosition.Latitude() ); |
|
683 TBool isLong = Math::IsNaN( CurrentPosition.Longitude () ); |
|
684 TBool isAlt = Math::IsNaN( CurrentPosition.Altitude () ); |
|
685 |
|
686 if( noOfSatUsed >= 4 && noOfSatInView > 4 ) |
|
687 { |
|
688 for(TInt i = 0;i < noOfSatUsed ;i++ ) |
|
689 { |
|
690 User::LeaveIfError(iPositionInfo.GetSatelliteData(i,tempSatelliteData)); |
|
691 totalStrength += tempSatelliteData.SignalStrength(); |
|
692 } |
|
693 TInt avgStrength = totalStrength / noOfSatUsed; |
|
694 if( avgStrength >= 40 && |
|
695 !isLat && |
|
696 !isLong && |
|
697 !isAlt ) |
|
698 { |
|
699 aNumSatellites = 4; |
|
700 } |
|
701 else |
|
702 { |
|
703 aNumSatellites = 3; |
|
704 } |
|
705 } |
|
706 else if ( noOfSatUsed < 4 && noOfSatInView >= 4 ) |
|
707 { |
|
708 aNumSatellites = 2; |
|
709 } |
|
710 else if ( noOfSatUsed < 4 && noOfSatInView < 4 ) |
|
711 { |
|
712 aNumSatellites = 1; |
|
713 } |
|
714 else |
|
715 { |
|
716 aNumSatellites = 0; |
|
717 } |
|
718 } |
|
719 |
|
720 // ---------------------------------------------------------------------------- |
|
721 // CBlidLocation::ResetMaxSpeed |
|
722 // ---------------------------------------------------------------------------- |
|
723 // |
|
724 void CBlidLocation::ResetMaxSpeed() |
|
725 { |
|
726 iMaxSpeed = 0.0; |
|
727 } |
|
728 |
|
729 |
|
730 // ---------------------------------------------------------------------------- |
|
731 // CBlidLocation::ResetAvgSpeed |
|
732 // ---------------------------------------------------------------------------- |
|
733 // |
|
734 void CBlidLocation::ResetAvgSpeed() |
|
735 { |
|
736 iSpeedAverage= 0.0; |
|
737 } |
|
738 |
|
739 |
|
740 // ---------------------------------------------------------------------------- |
|
741 // CBlidLocation::CalculateTripTimeL |
|
742 // ---------------------------------------------------------------------------- |
|
743 // |
|
744 void CBlidLocation::CalculateTripTimeL() |
|
745 { |
|
746 TTime curTime; |
|
747 curTime.UniversalTime(); |
|
748 curTime.SecondsFrom(iInitTripTime,iTripInterval); |
|
749 } |
|
750 |
|
751 // ---------------------------------------------------------------------------- |
|
752 // CBlidLocation::CalculateTotalTimeL |
|
753 // ---------------------------------------------------------------------------- |
|
754 // |
|
755 void CBlidLocation::CalculateTotalTimeL() |
|
756 { |
|
757 TTime curTime; |
|
758 curTime.UniversalTime(); |
|
759 if( iIsTripStart ) |
|
760 { |
|
761 curTime.SecondsFrom(iInitViewTime,iTotalInterval); |
|
762 } |
|
763 } |
|
764 |
|
765 |
|
766 // ---------------------------------------------------------------------------- |
|
767 // CBlidLocation::UpdateTripData |
|
768 // ---------------------------------------------------------------------------- |
|
769 // |
|
770 void CBlidLocation::UpdateTripData( ) |
|
771 { |
|
772 if( iIsTripStart ) |
|
773 { |
|
774 TReal32 distance; |
|
775 TPosition& pos = GetCurrentPosition(); |
|
776 TReal32 max = Max(pos.HorizontalAccuracy(), iPrevPosition.HorizontalAccuracy()); |
|
777 |
|
778 if(iPrevPosition.Distance(pos, distance) == KErrNone) |
|
779 { |
|
780 TBool fixConsidered = EFalse; |
|
781 if( distance > max ) |
|
782 { |
|
783 iDistanceTravelled += distance; |
|
784 iTotalDistanceTravelled += distance; |
|
785 iPrevPosition = TPosition(pos); |
|
786 fixConsidered = ETrue; |
|
787 } |
|
788 else |
|
789 { |
|
790 TReal32 speed = iCourse.Speed(); |
|
791 if(speed > KBlidCutOffSpeed) |
|
792 { |
|
793 iDistanceTravelled += distance; |
|
794 iTotalDistanceTravelled += distance; |
|
795 iPrevPosition = TPosition(pos); |
|
796 fixConsidered = ETrue; |
|
797 } |
|
798 } |
|
799 if(fixConsidered) |
|
800 { |
|
801 // Evaluated Trip Speeds if fix considered |
|
802 TReal32 currentSpeed = iCourse.Speed(); |
|
803 if( currentSpeed > iTripMaxSpeed) |
|
804 { |
|
805 iTripMaxSpeed = currentSpeed; |
|
806 } |
|
807 |
|
808 TInt time = iTripInterval.Int(); |
|
809 iTripAverageSpeed = iDistanceTravelled / time; |
|
810 |
|
811 if(iTripAverageSpeed > iTripMaxSpeed) |
|
812 { |
|
813 iTripAverageSpeed = iTripMaxSpeed; |
|
814 } |
|
815 } |
|
816 } |
|
817 else |
|
818 { |
|
819 iDistanceTravelled = 0; |
|
820 iTotalDistanceTravelled = 0; |
|
821 } |
|
822 |
|
823 iIsDistanceTravelled = ETrue; |
|
824 } |
|
825 } |
|
826 |
|
827 // ---------------------------------------------------------------------------- |
|
828 // CBlidLocation::GetTripTime |
|
829 // ---------------------------------------------------------------------------- |
|
830 // |
|
831 void CBlidLocation::GetTripTime( TTimeIntervalSeconds& aTime ) |
|
832 { |
|
833 aTime = iTripInterval; |
|
834 } |
|
835 |
|
836 // ---------------------------------------------------------------------------- |
|
837 // CBlidLocation::GetTripTime |
|
838 // ---------------------------------------------------------------------------- |
|
839 // |
|
840 void CBlidLocation::GetTotalTime( TTimeIntervalSeconds& aTime ) |
|
841 { |
|
842 aTime = iTotalInterval; |
|
843 } |
|
844 |
|
845 // ---------------------------------------------------------------------------- |
|
846 // CBlidLocation::IsTripDistanceTravelled |
|
847 // ---------------------------------------------------------------------------- |
|
848 // |
|
849 TBool CBlidLocation::IsTripDistanceTravelled( ) |
|
850 { |
|
851 return iIsDistanceTravelled; |
|
852 } |
|
853 |
|
854 // ---------------------------------------------------------------------------- |
|
855 // CBlidLocation::GetTripDistance |
|
856 // ---------------------------------------------------------------------------- |
|
857 // |
|
858 void CBlidLocation::GetTripDistance(TReal32& aDistance ) |
|
859 { |
|
860 aDistance = iDistanceTravelled; |
|
861 } |
|
862 |
|
863 // ---------------------------------------------------------------------------- |
|
864 // CBlidLocation::GetTotalDistance |
|
865 // ---------------------------------------------------------------------------- |
|
866 // |
|
867 void CBlidLocation::GetTotalDistance(TReal32& aDistance ) |
|
868 { |
|
869 aDistance = iTotalDistanceTravelled; |
|
870 } |
|
871 |
|
872 // ---------------------------------------------------------------------------- |
|
873 // CBlidLocation::IsTotalDistanceTravelled |
|
874 // ---------------------------------------------------------------------------- |
|
875 // |
|
876 TBool CBlidLocation::IsTotalDistanceTravelled( ) |
|
877 { |
|
878 return iIsDistance; |
|
879 } |
|
880 |
|
881 // ---------------------------------------------------------------------------- |
|
882 // CBlidLocation::SetTripStartL |
|
883 // ---------------------------------------------------------------------------- |
|
884 // |
|
885 void CBlidLocation::SetTripStartL() |
|
886 { |
|
887 if( !iIsTripStart ) |
|
888 { |
|
889 iIsTripStart = ETrue; |
|
890 iIsTripNotStart = EFalse; |
|
891 iIsTripClear = EFalse; |
|
892 iInitTripTime.UniversalTime(); |
|
893 iInitViewTime.UniversalTime(); |
|
894 iDistanceTravelled = 0.0; |
|
895 if(iOnlineMode) |
|
896 { |
|
897 iPrevPosition = GetCurrentPosition(); |
|
898 iIsPreviousPositionUpdated = ETrue; |
|
899 } |
|
900 else |
|
901 { |
|
902 iIsPreviousPositionUpdated = EFalse; |
|
903 } |
|
904 |
|
905 if(iTimer) |
|
906 { |
|
907 delete iTimer; |
|
908 iTimer = NULL; |
|
909 } |
|
910 |
|
911 iTimer = CPeriodic::NewL(CActive::EPriorityHigh); |
|
912 TCallBack callback(TimerCallBackFunctionL, this); |
|
913 iTimer->Start( TTimeIntervalMicroSeconds32(1000000), |
|
914 TTimeIntervalMicroSeconds32(1000000), |
|
915 callback ); |
|
916 } |
|
917 } |
|
918 |
|
919 // ---------------------------------------------------------------------------- |
|
920 // CBlidLocation::HasTripStarted |
|
921 // ---------------------------------------------------------------------------- |
|
922 // |
|
923 TBool CBlidLocation::HasTripStarted() |
|
924 { |
|
925 return iIsTripStart; |
|
926 } |
|
927 |
|
928 // ---------------------------------------------------------------------------- |
|
929 // CBlidLocation::SetTripStop |
|
930 // ---------------------------------------------------------------------------- |
|
931 // |
|
932 void CBlidLocation::SetTripStop() |
|
933 { |
|
934 iIsTripStart = EFalse; |
|
935 //iIsTripNotStart = EFalse; |
|
936 if(iOnlineMode) |
|
937 { |
|
938 iWasGPSDataAvailableOnTripStop = ETrue; |
|
939 } |
|
940 else |
|
941 { |
|
942 iWasGPSDataAvailableOnTripStop = EFalse; |
|
943 } |
|
944 iStoppedTime.UniversalTime(); |
|
945 if(iTimer) |
|
946 { |
|
947 delete iTimer; |
|
948 iTimer = NULL; |
|
949 } |
|
950 } |
|
951 |
|
952 // ---------------------------------------------------------------------------- |
|
953 // CBlidLocation::HasTripStarted |
|
954 // ---------------------------------------------------------------------------- |
|
955 // |
|
956 TBool CBlidLocation::HasTripNotStarted() |
|
957 { |
|
958 return iIsTripNotStart; |
|
959 } |
|
960 |
|
961 // ---------------------------------------------------------------------------- |
|
962 // CBlidLocation::HasTripStarted |
|
963 // ---------------------------------------------------------------------------- |
|
964 // |
|
965 TBool CBlidLocation::WasGPSAvailableOnTripStop() |
|
966 { |
|
967 return iWasGPSDataAvailableOnTripStop; |
|
968 } |
|
969 |
|
970 // ---------------------------------------------------------------------------- |
|
971 // CBlidLocation::ResetTrip |
|
972 // ---------------------------------------------------------------------------- |
|
973 // |
|
974 void CBlidLocation::ResetTrip() |
|
975 { |
|
976 if(iIsTripStart == EFalse) |
|
977 { |
|
978 iIsTripReset = ETrue; |
|
979 } |
|
980 else |
|
981 { |
|
982 iIsTripReset = EFalse; |
|
983 } |
|
984 |
|
985 iDurationInSeconds = 0.0; |
|
986 iDistanceTravelled = 0.0; |
|
987 iTripTime = 0; |
|
988 iTripInterval = 0; |
|
989 iInitTripTime.UniversalTime(); |
|
990 iTripAverageSpeed = 0.0; |
|
991 iTripMaxSpeed = 0.0; |
|
992 } |
|
993 |
|
994 // ---------------------------------------------------------------------------- |
|
995 // CBlidLocation::Restart |
|
996 // ---------------------------------------------------------------------------- |
|
997 // |
|
998 /*void CBlidLocation::Restart() |
|
999 { |
|
1000 iDurationInSeconds = 0.0; |
|
1001 iDistanceTravelled = 0.0; |
|
1002 //iTotalDistanceTravelled = 0.0; |
|
1003 iTotalDurationInSeconds = 0.0; |
|
1004 iWasGPSDataAvailableOnTripStop = EFalse; |
|
1005 iTripTime = 0; |
|
1006 iTotalTime = 0; |
|
1007 iTripInterval = 0; |
|
1008 iTotalInterval = 0; |
|
1009 iInitViewTime.UniversalTime(); |
|
1010 iInitTripTime.UniversalTime(); |
|
1011 iIsTripNotStart = EFalse; |
|
1012 iTripAverageSpeed = 0.0; |
|
1013 iTripMaxSpeed = 0.0; |
|
1014 }*/ |
|
1015 |
|
1016 // ---------------------------------------------------------------------------- |
|
1017 // CBlidLocation::SetTripResumeL |
|
1018 // ---------------------------------------------------------------------------- |
|
1019 // |
|
1020 void CBlidLocation::SetTripResumeL() |
|
1021 { |
|
1022 iIsTripStart = ETrue; |
|
1023 iIsTripNotStart = EFalse; |
|
1024 iWasGPSDataAvailableOnTripStop = EFalse; |
|
1025 iTimer = CPeriodic::NewL(CActive::EPriorityHigh); |
|
1026 TCallBack callback(TimerCallBackFunctionL, this); |
|
1027 iTimer->Start( TTimeIntervalMicroSeconds32(1000000), |
|
1028 TTimeIntervalMicroSeconds32(1000000), |
|
1029 callback ); |
|
1030 TTime curTime; |
|
1031 curTime.UniversalTime(); |
|
1032 TTimeIntervalMicroSeconds interval; |
|
1033 interval = curTime.MicroSecondsFrom(iStoppedTime); |
|
1034 |
|
1035 if(iStoppedTime > iInitViewTime ) |
|
1036 { |
|
1037 iInitViewTime = iInitViewTime + interval; |
|
1038 } |
|
1039 |
|
1040 if(iIsTripReset) |
|
1041 { |
|
1042 iInitTripTime.UniversalTime(); |
|
1043 iIsTripReset = EFalse; |
|
1044 } |
|
1045 else if(iStoppedTime > iInitTripTime ) |
|
1046 { |
|
1047 iInitTripTime = iInitTripTime + interval; |
|
1048 } |
|
1049 |
|
1050 if(iIsTripStart) |
|
1051 { |
|
1052 CalculateTripTimeL(); |
|
1053 } |
|
1054 CalculateTotalTimeL(); |
|
1055 |
|
1056 if(iObserver) |
|
1057 { |
|
1058 if(iOnlineMode) |
|
1059 { |
|
1060 iObserver->NotifyL(iOnlineMode); |
|
1061 } |
|
1062 else |
|
1063 { |
|
1064 iObserver->NotifyErrorL(KErrUnknown); |
|
1065 } |
|
1066 } |
|
1067 } |
|
1068 |
|
1069 // ---------------------------------------------------------------------------- |
|
1070 // CBlidLocation::SetTripClear |
|
1071 // ---------------------------------------------------------------------------- |
|
1072 // |
|
1073 void CBlidLocation::SetTripClear() |
|
1074 { |
|
1075 iIsTripClear = ETrue; |
|
1076 iIsTripStart = EFalse; |
|
1077 iIsTripReset = EFalse; |
|
1078 iIsDistance = ETrue; |
|
1079 iWasGPSDataAvailableOnTripStop = EFalse; |
|
1080 iTripAverageSpeed = 0.0; |
|
1081 iTripMaxSpeed = 0.0; |
|
1082 iTripGPSDataLost = EFalse; |
|
1083 iIsTripNotStart = ETrue; |
|
1084 |
|
1085 iDurationInSeconds = 0.0; |
|
1086 iDistanceTravelled = 0.0; |
|
1087 iTotalDurationInSeconds = 0.0; |
|
1088 iTripTime = 0; |
|
1089 iTotalTime = 0; |
|
1090 iTripInterval = 0; |
|
1091 iTotalInterval = 0; |
|
1092 iInitViewTime.UniversalTime(); |
|
1093 iInitTripTime.UniversalTime(); |
|
1094 } |
|
1095 |
|
1096 // ---------------------------------------------------------------------------- |
|
1097 // CBlidLocation::IsTripCleared |
|
1098 // ---------------------------------------------------------------------------- |
|
1099 // |
|
1100 TBool CBlidLocation::IsTripCleared() |
|
1101 { |
|
1102 return iIsTripClear; |
|
1103 } |
|
1104 |
|
1105 // ---------------------------------------------------------------------------- |
|
1106 // CBlidLocation::ResetTripClear |
|
1107 // ---------------------------------------------------------------------------- |
|
1108 // |
|
1109 void CBlidLocation::ResetTripClear() |
|
1110 { |
|
1111 iIsTripClear = EFalse; |
|
1112 iInitTripTime.UniversalTime(); |
|
1113 iInitViewTime.UniversalTime(); |
|
1114 } |
|
1115 |
|
1116 |
|
1117 // ---------------------------------------------------------------------------- |
|
1118 // CBlidLocation::ResetTripClear |
|
1119 // ---------------------------------------------------------------------------- |
|
1120 // |
|
1121 TBool CBlidLocation::IsTripReset() |
|
1122 { |
|
1123 return iIsTripReset; |
|
1124 } |
|
1125 |
|
1126 // ---------------------------------------------------------------------------- |
|
1127 // CBlidLocation::TimerCallBackL |
|
1128 // ---------------------------------------------------------------------------- |
|
1129 // |
|
1130 void CBlidLocation::TimerCallBackL() |
|
1131 { |
|
1132 if(iIsTripStart) |
|
1133 { |
|
1134 CalculateTripTimeL(); |
|
1135 } |
|
1136 CalculateTotalTimeL(); |
|
1137 |
|
1138 if(iObserver) |
|
1139 { |
|
1140 if(iOnlineMode) |
|
1141 { |
|
1142 iObserver->NotifyL(iOnlineMode); |
|
1143 } |
|
1144 else |
|
1145 { |
|
1146 iObserver->NotifyErrorL(KErrUnknown); |
|
1147 } |
|
1148 } |
|
1149 } |
|
1150 |
|
1151 // ---------------------------------------------------------------------------- |
|
1152 // CBlidLocation::GetHeading |
|
1153 // ---------------------------------------------------------------------------- |
|
1154 // |
|
1155 TReal32 CBlidLocation::GetHeading() |
|
1156 { |
|
1157 return iHeading; |
|
1158 } |
|
1159 |
|
1160 // ---------------------------------------------------------------------------- |
|
1161 // CBlidLocation::CalculateCourse |
|
1162 // ---------------------------------------------------------------------------- |
|
1163 // |
|
1164 void CBlidLocation::CalculateCourse() |
|
1165 { |
|
1166 TReal32 distance; |
|
1167 TPosition& pos = GetCurrentPosition(); |
|
1168 TReal32 max = Max(pos.HorizontalAccuracy(), iPrevPosition.HorizontalAccuracy()); |
|
1169 |
|
1170 if(iPrevCoursePosition.Distance(pos, distance) == KErrNone) |
|
1171 { |
|
1172 if( distance > 0.2 * max ) |
|
1173 { |
|
1174 iHeading = iCourse.Heading(); |
|
1175 iPrevCoursePosition = TPosition(pos); |
|
1176 } |
|
1177 } |
|
1178 else |
|
1179 { |
|
1180 iPrevCoursePosition = TPosition(pos); |
|
1181 } |
|
1182 } |
|
1183 |
|
1184 // ---------------------------------------------------------------------------- |
|
1185 // CBlidLocation::CheckGPSAvailability |
|
1186 // ---------------------------------------------------------------------------- |
|
1187 // |
|
1188 TInt CBlidLocation::CheckGPSAvailability() |
|
1189 { |
|
1190 TPositionModuleStatus lPosModuleStatus; |
|
1191 GetModuleInfoStatus(lPosModuleStatus); |
|
1192 TInt retVal = lPosModuleStatus.DeviceStatus(); |
|
1193 |
|
1194 |
|
1195 if ((retVal == TPositionModuleStatus::EDeviceError) || |
|
1196 (retVal == TPositionModuleStatus::EDeviceStandBy) || |
|
1197 (retVal == TPositionModuleStatus::EDeviceUnknown) ) |
|
1198 { |
|
1199 // GPS device unavailable |
|
1200 return 0; |
|
1201 } |
|
1202 else if( (retVal == TPositionModuleStatus::EDeviceReady) || |
|
1203 (retVal == TPositionModuleStatus::EDeviceActive) || |
|
1204 (retVal == TPositionModuleStatus::EDeviceInactive) ) |
|
1205 { |
|
1206 // GPS device is paired and available |
|
1207 return 1; |
|
1208 } |
|
1209 // GPS device connections is being established |
|
1210 return -1; |
|
1211 } |
|
1212 |
|
1213 // ---------------------------------------------------------------------------- |
|
1214 // CBlidLocation::IsGPSDataAvailable |
|
1215 // ---------------------------------------------------------------------------- |
|
1216 // |
|
1217 TBool CBlidLocation::IsGPSDataAvailable() |
|
1218 { |
|
1219 return iGPSDataAvailable; |
|
1220 } |
|
1221 |
|
1222 // ---------------------------------------------------------------------------- |
|
1223 // CBlidLocation::WasGPSDataLost |
|
1224 // ---------------------------------------------------------------------------- |
|
1225 // |
|
1226 TBool CBlidLocation::WasGPSDataLost() |
|
1227 { |
|
1228 return iTripGPSDataLost; |
|
1229 } |
|
1230 |
|
1231 // ---------------------------------------------------------------------------- |
|
1232 // CBlidLocation::SetGPSDataAvailability |
|
1233 // ---------------------------------------------------------------------------- |
|
1234 // |
|
1235 void CBlidLocation::SetGPSDataAvailability(TBool aAvailability) |
|
1236 { |
|
1237 iTripGPSDataLost = aAvailability; |
|
1238 } |
|
1239 |
|
1240 // ---------------------------------------------------------------------------- |
|
1241 // CBlidLocation::GetTripAverageSpeed |
|
1242 // ---------------------------------------------------------------------------- |
|
1243 // |
|
1244 TReal32 CBlidLocation::GetTripAverageSpeed() |
|
1245 { |
|
1246 return iTripAverageSpeed; |
|
1247 } |
|
1248 |
|
1249 // ---------------------------------------------------------------------------- |
|
1250 // CBlidLocation::GetTripAverageSpeed |
|
1251 // ---------------------------------------------------------------------------- |
|
1252 // |
|
1253 TReal32 CBlidLocation::GetTripMaxSpeed() |
|
1254 { |
|
1255 TReal32 currentSpeed = iCourse.Speed(); |
|
1256 return currentSpeed; |
|
1257 } |
|
1258 |
|
1259 // ---------------------------------------------------------------------------- |
|
1260 // CBlidLocation::GetModuleInfoNotification |
|
1261 // ---------------------------------------------------------------------------- |
|
1262 // |
|
1263 void CBlidLocation::GetModuleInfoNotificationL() |
|
1264 { |
|
1265 iModuleInfoArray.Reset(); |
|
1266 User::LeaveIfError( iServer.GetNumModules(iModuleCount) ); |
|
1267 TPositionModuleInfo moduleInfo; |
|
1268 |
|
1269 for( TUint i = 0; i < iModuleCount; i++ ) |
|
1270 { |
|
1271 User::LeaveIfError( iServer.GetModuleInfoByIndex( i, moduleInfo ) ); |
|
1272 iModuleInfoArray.Append(moduleInfo); |
|
1273 } |
|
1274 } |
|
1275 |
|
1276 // ---------------------------------------------------------------------------- |
|
1277 // CBlidLocation::SetNavigationStart |
|
1278 // ---------------------------------------------------------------------------- |
|
1279 // |
|
1280 void CBlidLocation::SetNavigationStart( TBool aNavigationStart ) |
|
1281 { |
|
1282 if( !aNavigationStart ) |
|
1283 { |
|
1284 iIsTripStart = EFalse; |
|
1285 } |
|
1286 else |
|
1287 { |
|
1288 iIsTripStart = ETrue; |
|
1289 } |
|
1290 |
|
1291 if( !iIsTripStart ) |
|
1292 { |
|
1293 // delete the timer because the stop trip will not be get called |
|
1294 // or else it will leads to memory leak |
|
1295 if(iTimer) |
|
1296 { |
|
1297 delete iTimer; |
|
1298 iTimer = NULL; |
|
1299 } |
|
1300 } |
|
1301 } |
|
1302 |
|
1303 // ---------------------------------------------------------------------------- |
|
1304 // CBlidLocation::ResetOdometerValue |
|
1305 // ---------------------------------------------------------------------------- |
|
1306 // |
|
1307 void CBlidLocation::ResetOdometerValue() |
|
1308 { |
|
1309 iTotalDistanceTravelled = 0.0; |
|
1310 } |
|
1311 |
|
1312 |
|
1313 // ---------------------------------------------------------------------------- |
|
1314 // CBlidLocation::IsSatCapablePsyAvailable |
|
1315 // ---------------------------------------------------------------------------- |
|
1316 // |
|
1317 TBool CBlidLocation::IsSatCapablePsyAvailable() |
|
1318 { |
|
1319 TUint numberOfModules; |
|
1320 TPositionModuleInfo moduleInfo; |
|
1321 numberOfModules = iModuleInfoArray.Count(); |
|
1322 |
|
1323 if( numberOfModules > 0) |
|
1324 { |
|
1325 moduleInfo = iModuleInfoArray[ 1 ]; |
|
1326 if ( (moduleInfo.Capabilities() & |
|
1327 TPositionModuleInfo::ECapabilitySatellite ) && |
|
1328 !moduleInfo.IsAvailable() ) |
|
1329 { |
|
1330 return ETrue; |
|
1331 } |
|
1332 } |
|
1333 return EFalse; |
|
1334 } |
|
1335 |
|
1336 // ---------------------------------------------------------------------------- |
|
1337 // CBlidLocation::NumberOfSatellitesVisible |
|
1338 // ---------------------------------------------------------------------------- |
|
1339 // |
|
1340 TInt CBlidLocation::NumberOfSatellitesVisible() |
|
1341 { |
|
1342 return iPositionInfo.NumSatellitesInView(); |
|
1343 } |
|
1344 |
|
1345 // ---------------------------------------------------------------------------- |
|
1346 // CBlidLocation::IsSatellitesUsed |
|
1347 // ---------------------------------------------------------------------------- |
|
1348 // |
|
1349 TBool CBlidLocation::IsSatellitesUsed( TInt aIndex ) |
|
1350 { |
|
1351 TBool lResult = EFalse; |
|
1352 TSatelliteData satData; |
|
1353 |
|
1354 if( GetSatelliteData( aIndex, satData ) != KErrNotFound) |
|
1355 { |
|
1356 lResult = satData.IsUsed(); |
|
1357 } |
|
1358 return lResult; |
|
1359 } |
|
1360 |
|
1361 // ---------------------------------------------------------------------------- |
|
1362 // CBlidLocation::SortSatelliteDataL |
|
1363 // ---------------------------------------------------------------------------- |
|
1364 // |
|
1365 void CBlidLocation::SortSatelliteDataL() |
|
1366 { |
|
1367 TSatelliteData tempSatelliteData; |
|
1368 TLinearOrder<TSatelliteData> order(SortCriteria); |
|
1369 iSortedSatData.Reset(); |
|
1370 TInt satellitesInView = iPositionInfo.NumSatellitesInView(); |
|
1371 for(TInt i = 0;i < satellitesInView ;i++ ) |
|
1372 { |
|
1373 User::LeaveIfError(iPositionInfo.GetSatelliteData(i,tempSatelliteData)); |
|
1374 TInt signalsth = tempSatelliteData.SignalStrength(); |
|
1375 iSortedSatData.InsertInOrderAllowRepeats(tempSatelliteData, order); |
|
1376 } |
|
1377 } |
|
1378 |
|
1379 // ---------------------------------------------------------------------------- |
|
1380 // CBlidLocation::GetSatelliteSignalStrength |
|
1381 // ---------------------------------------------------------------------------- |
|
1382 // |
|
1383 TInt CBlidLocation::GetSatelliteSignalStrength( TInt aIndex ) |
|
1384 { |
|
1385 TSatelliteData satData; |
|
1386 |
|
1387 if( GetSatelliteData( aIndex, satData ) != KErrNotFound ) |
|
1388 { |
|
1389 if( satData.SignalStrength() < KMinSatelliteSignalStrength ) |
|
1390 { |
|
1391 return 0; |
|
1392 } |
|
1393 else if( satData.SignalStrength() == KMinSatelliteSignalStrength ) |
|
1394 { |
|
1395 return 1; |
|
1396 } |
|
1397 else if( satData.SignalStrength() > KMinSatelliteSignalStrength && |
|
1398 satData.SignalStrength() < KMidSatelliteSignalStrength ) |
|
1399 { |
|
1400 return 2; |
|
1401 } |
|
1402 else if( satData.SignalStrength() > KMidSatelliteSignalStrength && |
|
1403 satData.SignalStrength() < KMaxSatelliteSignalStrength ) |
|
1404 { |
|
1405 return 3; |
|
1406 } |
|
1407 else if( satData.SignalStrength() > KMaxSatelliteSignalStrength ) |
|
1408 { |
|
1409 return 4; |
|
1410 } |
|
1411 } |
|
1412 return 0; |
|
1413 } |
|
1414 |
|
1415 // ---------------------------------------------------------------------------- |
|
1416 // CBlidLocation::GetSatelliteData |
|
1417 // ---------------------------------------------------------------------------- |
|
1418 // |
|
1419 TInt CBlidLocation::GetSatelliteData( TUint aIndex, |
|
1420 TSatelliteData& aSatelliteData) |
|
1421 { |
|
1422 if( aIndex >= iSortedSatData.Count() ) |
|
1423 { |
|
1424 return KErrNotFound; |
|
1425 } |
|
1426 aSatelliteData = iSortedSatData[aIndex]; |
|
1427 return KErrNone; |
|
1428 } |
|
1429 |
|
1430 // ---------------------------------------------------------------------------- |
|
1431 // CBlidLocation::GetSatelliteNo |
|
1432 // ---------------------------------------------------------------------------- |
|
1433 // |
|
1434 TInt CBlidLocation::GetSatelliteNo( TInt aIndex ) |
|
1435 { |
|
1436 TSatelliteData satData; |
|
1437 |
|
1438 if( GetSatelliteData( aIndex, satData ) != KErrNotFound) |
|
1439 { |
|
1440 return satData.SatelliteId(); |
|
1441 } |
|
1442 return 0; |
|
1443 } |
|
1444 |
|
1445 // ---------------------------------------------------------------------------- |
|
1446 // SortCriteria |
|
1447 // ---------------------------------------------------------------------------- |
|
1448 // |
|
1449 TInt SortCriteria(const TSatelliteData& aFirst, const TSatelliteData& aNext) |
|
1450 { |
|
1451 if(aFirst.SatelliteId() > aNext.SatelliteId()) |
|
1452 { |
|
1453 return 1; |
|
1454 } |
|
1455 else if(aFirst.SatelliteId() < aNext.SatelliteId()) |
|
1456 { |
|
1457 return -1; |
|
1458 } |
|
1459 return 0; |
|
1460 } |
|
1461 |
|
1462 // ---------------------------------------------------------------------------- |
|
1463 // TimerCallBackFunctionL |
|
1464 // ---------------------------------------------------------------------------- |
|
1465 // |
|
1466 TInt TimerCallBackFunctionL(TAny* aPtr) |
|
1467 { |
|
1468 CBlidLocation* ptr = static_cast<CBlidLocation*>(aPtr); |
|
1469 ptr->TimerCallBackL(); |
|
1470 return 1; |
|
1471 } |
|
1472 |
|
1473 // End of File |
|
1474 |