|
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 |
|
306 /// Check if we have satellite data |
|
307 if(!(iStatus.Int() == KErrNone || |
|
308 iStatus.Int() == KPositionPartialUpdate) ) |
|
309 { |
|
310 iPositionInfo.ClearSatellitesInView(); |
|
311 } |
|
312 SortSatelliteDataL(); |
|
313 |
|
314 switch ( iStatus.Int() ) |
|
315 { |
|
316 //case KPositionPartialUpdate: |
|
317 case KErrNone: // Success |
|
318 { |
|
319 iOnlineMode = ETrue; |
|
320 iUpdateReceived = ETrue; |
|
321 iGPSDataAvailable = ETrue; |
|
322 iPositionInfo.GetPosition( iPosition ); |
|
323 iPositionInfo.GetCourse( iCourse ); |
|
324 iLastGoodFixTime.UniversalTime(); |
|
325 |
|
326 CalculateCourse(); |
|
327 |
|
328 if(iIsTripStart) |
|
329 { |
|
330 if(!iIsPreviousPositionUpdated) |
|
331 { |
|
332 iIsPreviousPositionUpdated = ETrue; |
|
333 iPrevPosition = GetCurrentPosition(); |
|
334 } |
|
335 UpdateTripData(); |
|
336 } |
|
337 |
|
338 //SortSatelliteDataL(); |
|
339 |
|
340 if(iObserver) |
|
341 { |
|
342 iObserver->NotifyL( iOnlineMode ); |
|
343 } |
|
344 if ( iRequesting ) |
|
345 { |
|
346 //DEBUG("KErrNone : NotifyPositionUpdate"); |
|
347 iPositioner.NotifyPositionUpdate( iPositionInfo, iStatus ); |
|
348 SetActive(); |
|
349 } |
|
350 break; |
|
351 } |
|
352 case KErrAccessDenied: |
|
353 /* |
|
354 Happens if we don't specify requestor information. |
|
355 This condition should not be encountered. |
|
356 */ |
|
357 { |
|
358 iRequesting = EFalse; |
|
359 User::Leave( KErrAccessDenied ); |
|
360 break; |
|
361 } |
|
362 case KErrCancel: // Postion update request cancelled |
|
363 { |
|
364 // We canceled the request so do nothing |
|
365 break; |
|
366 } |
|
367 case KPositionPartialUpdate: // Incomplete position information |
|
368 { |
|
369 if ( iRequesting ) |
|
370 { |
|
371 //DEBUG("KPositionPartialUpdate : NotifyPositionUpdate"); |
|
372 iPositioner.NotifyPositionUpdate( iPositionInfo, iStatus ); |
|
373 SetActive(); |
|
374 } |
|
375 break; |
|
376 } |
|
377 case KErrTimedOut: // Position update timed out |
|
378 case KPositionQualityLoss: //GPS not connected |
|
379 { |
|
380 iUpdateReceived = ETrue; |
|
381 iGPSDataAvailable = EFalse; |
|
382 if(iIsTripStart && !iIsTripClear) |
|
383 { |
|
384 iTripGPSDataLost = ETrue; |
|
385 } |
|
386 // Leaving break is intentional |
|
387 } |
|
388 //-fallthrough |
|
389 case KErrNotFound: // No PSY selected. |
|
390 case KErrUnknown: // This will be returned by MLFW |
|
391 case KErrArgument: |
|
392 /* |
|
393 PSY does not support the information type specified |
|
394 by BLID. |
|
395 */ |
|
396 default: |
|
397 { |
|
398 if(iStatus.Int() != KPositionPartialUpdate ) |
|
399 { |
|
400 iDeviceStatus = EDeviceNotFound; |
|
401 iPositionInfo.ClearSatellitesInView(); |
|
402 iWaitingGpsData = EFalse; |
|
403 } |
|
404 // added for TSW error. |
|
405 if(iStatus.Int() == KPositionPartialUpdate ) |
|
406 { |
|
407 //SortSatelliteDataL(); |
|
408 TTime now; |
|
409 now.UniversalTime(); |
|
410 TTimeIntervalSeconds secondsSinceLastGoodFix; |
|
411 now.SecondsFrom( iLastGoodFixTime , secondsSinceLastGoodFix ); |
|
412 if ( secondsSinceLastGoodFix.Int() > 15 ) |
|
413 { |
|
414 iLastGoodFixTime.UniversalTime(); |
|
415 if(iObserver) |
|
416 { |
|
417 iObserver->NotifyErrorL( KErrTimedOut ); |
|
418 } |
|
419 } |
|
420 } |
|
421 else |
|
422 { |
|
423 iLastGoodFixTime.UniversalTime(); |
|
424 } |
|
425 // end of addition for TSW error |
|
426 |
|
427 iGPSDataAvailable = EFalse; |
|
428 iUpdateReceived = ETrue; |
|
429 |
|
430 // All cases are errors and hence go to offline mode |
|
431 iOnlineMode = EFalse; |
|
432 if(iObserver) |
|
433 { |
|
434 iObserver->NotifyErrorL(iStatus.Int()); |
|
435 } |
|
436 if ( iRequesting ) |
|
437 { |
|
438 |
|
439 iPositioner.NotifyPositionUpdate( iPositionInfo, iStatus ); |
|
440 SetActive(); |
|
441 } |
|
442 break; |
|
443 } |
|
444 } |
|
445 |
|
446 /*if( iStatus.Int() != KErrCancel ) |
|
447 { |
|
448 //DEBUG("RUNL : SetUpdateOptions"); |
|
449 SetUpdateOptions(); |
|
450 }*/ |
|
451 if(iStatus.Int() != KPositionPartialUpdate ) |
|
452 { |
|
453 iWaitingGpsData = CheckIfWaitingGPSData(); |
|
454 } |
|
455 } |
|
456 |
|
457 // ---------------------------------------------------------------------------- |
|
458 // CBlidLocation::SetUpdateOptions |
|
459 // ---------------------------------------------------------------------------- |
|
460 // |
|
461 void CBlidLocation::SetUpdateOptions() |
|
462 { |
|
463 if(IsActive()) |
|
464 { |
|
465 Cancel(); |
|
466 } |
|
467 // update interval |
|
468 TInt intervalTime = KMidIntervalTime; |
|
469 |
|
470 if(iEngine.AppMode() == CBlidEng::EAppBackground) // If application is in background mode |
|
471 { |
|
472 TRAP_IGNORE(UpdateIntervalL( KMaxIntervalTime )); |
|
473 if ( iRequesting ) |
|
474 { |
|
475 iPositioner.NotifyPositionUpdate( iPositionInfo, iStatus ); |
|
476 SetActive(); |
|
477 } |
|
478 return; |
|
479 } |
|
480 |
|
481 switch(iRegisteredViewId) |
|
482 { |
|
483 case EBlidNavigationView: |
|
484 { |
|
485 TReal32 distance; |
|
486 TInt retVal; |
|
487 retVal = iEngine.GetDistanceToDestination(distance); |
|
488 if(retVal == KErrNone) |
|
489 { |
|
490 if(distance <= KBlidHundredMeters) |
|
491 { |
|
492 intervalTime = KShortIntervalTime; |
|
493 } |
|
494 else if(distance > KBlidHundredMeters && |
|
495 distance < KBlidOneKilometer) |
|
496 { |
|
497 intervalTime = KMidIntervalTime; |
|
498 } |
|
499 else |
|
500 { |
|
501 intervalTime = KMaxIntervalTime; |
|
502 } |
|
503 } |
|
504 else |
|
505 { |
|
506 intervalTime = KShortIntervalTime; |
|
507 } |
|
508 break; |
|
509 } |
|
510 case EBlidTripMeterView: |
|
511 { |
|
512 if(iDistanceTravelled < KBlidHundredMeters) |
|
513 { |
|
514 intervalTime = KShortIntervalTime; |
|
515 } |
|
516 else if(iDistanceTravelled > KBlidHundredMeters && |
|
517 iDistanceTravelled < KBlidOneKilometer) |
|
518 { |
|
519 intervalTime = KMidIntervalTime; |
|
520 } |
|
521 else |
|
522 { |
|
523 intervalTime = KMaxIntervalTime; |
|
524 } |
|
525 break; |
|
526 } |
|
527 case EBlidMainView: |
|
528 default: |
|
529 { |
|
530 intervalTime = KMidIntervalTime; |
|
531 break; |
|
532 } |
|
533 } |
|
534 TRAP_IGNORE(UpdateIntervalL( intervalTime )); |
|
535 if ( iRequesting ) |
|
536 { |
|
537 iPositioner.NotifyPositionUpdate( iPositionInfo, iStatus ); |
|
538 SetActive(); |
|
539 } |
|
540 } |
|
541 |
|
542 // ---------------------------------------------------------------------------- |
|
543 // CBlidLocation::DoCancel |
|
544 // ---------------------------------------------------------------------------- |
|
545 // |
|
546 void CBlidLocation::DoCancel() |
|
547 { |
|
548 iPositioner.CancelRequest( EPositionerNotifyPositionUpdate ); |
|
549 } |
|
550 |
|
551 // ---------------------------------------------------------------------------- |
|
552 // CBlidLocation::RunError |
|
553 // ---------------------------------------------------------------------------- |
|
554 // |
|
555 TInt CBlidLocation::RunError(TInt aError) |
|
556 { |
|
557 if ( iObserver && aError != KBlidLeaveExit ) |
|
558 { |
|
559 TRAPD(error,iObserver->NotifyErrorL( aError )); |
|
560 if(error != KErrNone) |
|
561 { |
|
562 return error; |
|
563 } |
|
564 } |
|
565 return aError; |
|
566 } |
|
567 |
|
568 // ---------------------------------------------------------------------------- |
|
569 // CBlidLocation::UpdateIntervalL |
|
570 // ---------------------------------------------------------------------------- |
|
571 // |
|
572 void CBlidLocation::UpdateIntervalL( const TInt aIntervalTime ) |
|
573 { |
|
574 iCurrentUpdateInterval = aIntervalTime; |
|
575 TPositionUpdateOptions updateOptions; |
|
576 updateOptions.SetUpdateInterval(TTimeIntervalMicroSeconds(aIntervalTime)); |
|
577 updateOptions.SetAcceptPartialUpdates( ETrue ); |
|
578 if(iUpdateReceived) |
|
579 { |
|
580 updateOptions.SetUpdateTimeOut( TTimeIntervalMicroSeconds(KUpdateIntervalTimeOut)); |
|
581 } |
|
582 else |
|
583 { |
|
584 updateOptions.SetUpdateTimeOut( TTimeIntervalMicroSeconds(KStartUpdateIntervalTimeOut)); |
|
585 } |
|
586 User::LeaveIfError( iPositioner.SetUpdateOptions(updateOptions) ); |
|
587 } |
|
588 |
|
589 |
|
590 // ---------------------------------------------------------------------------- |
|
591 // CBlidLocation::GetCurrentUpdateInterval |
|
592 // ---------------------------------------------------------------------------- |
|
593 // |
|
594 void CBlidLocation:: GetCurrentUpdateInterval(TInt& aInterval) |
|
595 { |
|
596 aInterval = iCurrentUpdateInterval; |
|
597 } |
|
598 |
|
599 // ---------------------------------------------------------------------------- |
|
600 // CBlidLocation::GetPositionInfoStatus |
|
601 // ---------------------------------------------------------------------------- |
|
602 // |
|
603 TInt CBlidLocation::GetPositionInfoStatus() |
|
604 { |
|
605 return iPosStatus.Int(); |
|
606 } |
|
607 |
|
608 // ---------------------------------------------------------------------------- |
|
609 // CBlidLocation::CheckIfWaitingGPSData |
|
610 // ---------------------------------------------------------------------------- |
|
611 // |
|
612 TBool CBlidLocation::CheckIfWaitingGPSData() |
|
613 { |
|
614 if(iDeviceStatus == EDeviceUnderConnection) |
|
615 { |
|
616 return ETrue; |
|
617 } |
|
618 |
|
619 // If none of the above then check satellite status |
|
620 TInt num = iPositionInfo.NumSatellitesInView(); |
|
621 if(num > 0) |
|
622 { |
|
623 return ETrue; |
|
624 } |
|
625 return EFalse; |
|
626 } |
|
627 |
|
628 // ---------------------------------------------------------------------------- |
|
629 // CBlidLocation::GetRegisteredViewId |
|
630 // ---------------------------------------------------------------------------- |
|
631 // |
|
632 TInt CBlidLocation::GetRegisteredViewId() |
|
633 { |
|
634 return iRegisteredViewId; |
|
635 } |
|
636 |
|
637 // ---------------------------------------------------------------------------- |
|
638 // CBlidLocation::GetModuleInfoStatus |
|
639 // ---------------------------------------------------------------------------- |
|
640 // |
|
641 void CBlidLocation::GetModuleInfoStatus(TPositionModuleStatusBase& aPosModuleStatus) |
|
642 { |
|
643 // This function scan through the all satellite and selected PSY |
|
644 // and check the status of those PSY's if those are in Device err state. |
|
645 // |
|
646 TUint numberOfModules; |
|
647 TPositionModuleInfo moduleInfo; |
|
648 numberOfModules = iModuleInfoArray.Count(); |
|
649 |
|
650 if( numberOfModules > 0) |
|
651 { |
|
652 for( TInt i = 0; i < numberOfModules; i++ ) |
|
653 { |
|
654 moduleInfo = iModuleInfoArray[i]; |
|
655 if ( (moduleInfo.Capabilities() & |
|
656 TPositionModuleInfo::ECapabilitySatellite ) && |
|
657 moduleInfo.IsAvailable()) |
|
658 { |
|
659 TPositionModuleId moduleId = moduleInfo.ModuleId(); |
|
660 iServer.GetModuleStatus(aPosModuleStatus, moduleId); |
|
661 |
|
662 TPositionModuleStatus lPosModuleStatus; |
|
663 iServer.GetModuleStatus(lPosModuleStatus, moduleId); |
|
664 TInt resulterr = lPosModuleStatus.DeviceStatus(); |
|
665 |
|
666 if( (resulterr == TPositionModuleStatus::EDeviceError ) || |
|
667 (resulterr == TPositionModuleStatus::EDeviceInactive ) || |
|
668 (resulterr == TPositionModuleStatus::EDeviceStandBy ) ) |
|
669 { |
|
670 continue; |
|
671 } |
|
672 else |
|
673 { |
|
674 break; |
|
675 } |
|
676 } |
|
677 } |
|
678 } |
|
679 } |
|
680 |
|
681 // ---------------------------------------------------------------------------- |
|
682 // CBlidLocation::GetNumOfSatellitesL |
|
683 // ---------------------------------------------------------------------------- |
|
684 // |
|
685 void CBlidLocation::GetNumOfSatellitesL(TInt& aNumSatellites) |
|
686 { |
|
687 TSatelliteData tempSatelliteData; |
|
688 TPosition CurrentPosition; |
|
689 TInt totalStrength = 0; |
|
690 TInt noOfSatUsed = iPositionInfo.NumSatellitesUsed(); |
|
691 TInt noOfSatInView = iPositionInfo.NumSatellitesInView(); |
|
692 iPositionInfo.GetPosition( CurrentPosition ); |
|
693 TBool isLat = Math::IsNaN( CurrentPosition.Latitude() ); |
|
694 TBool isLong = Math::IsNaN( CurrentPosition.Longitude () ); |
|
695 TBool isAlt = Math::IsNaN( CurrentPosition.Altitude () ); |
|
696 |
|
697 if( noOfSatUsed >= 4 && noOfSatInView > 4 ) |
|
698 { |
|
699 for(TInt i = 0;i < noOfSatUsed ;i++ ) |
|
700 { |
|
701 User::LeaveIfError(iPositionInfo.GetSatelliteData(i,tempSatelliteData)); |
|
702 totalStrength += tempSatelliteData.SignalStrength(); |
|
703 } |
|
704 TInt avgStrength = totalStrength / noOfSatUsed; |
|
705 if( avgStrength >= 40 && |
|
706 !isLat && |
|
707 !isLong && |
|
708 !isAlt ) |
|
709 { |
|
710 aNumSatellites = 4; |
|
711 } |
|
712 else |
|
713 { |
|
714 aNumSatellites = 3; |
|
715 } |
|
716 } |
|
717 else if ( noOfSatUsed < 4 && noOfSatInView >= 4 ) |
|
718 { |
|
719 aNumSatellites = 2; |
|
720 } |
|
721 else if ( noOfSatUsed < 4 && noOfSatInView < 4 ) |
|
722 { |
|
723 aNumSatellites = 1; |
|
724 } |
|
725 else |
|
726 { |
|
727 aNumSatellites = 0; |
|
728 } |
|
729 } |
|
730 |
|
731 // ---------------------------------------------------------------------------- |
|
732 // CBlidLocation::ResetMaxSpeed |
|
733 // ---------------------------------------------------------------------------- |
|
734 // |
|
735 void CBlidLocation::ResetMaxSpeed() |
|
736 { |
|
737 iMaxSpeed = 0.0; |
|
738 } |
|
739 |
|
740 |
|
741 // ---------------------------------------------------------------------------- |
|
742 // CBlidLocation::ResetAvgSpeed |
|
743 // ---------------------------------------------------------------------------- |
|
744 // |
|
745 void CBlidLocation::ResetAvgSpeed() |
|
746 { |
|
747 iSpeedAverage= 0.0; |
|
748 } |
|
749 |
|
750 |
|
751 // ---------------------------------------------------------------------------- |
|
752 // CBlidLocation::CalculateTripTimeL |
|
753 // ---------------------------------------------------------------------------- |
|
754 // |
|
755 void CBlidLocation::CalculateTripTimeL() |
|
756 { |
|
757 TTime curTime; |
|
758 curTime.UniversalTime(); |
|
759 curTime.SecondsFrom(iInitTripTime,iTripInterval); |
|
760 } |
|
761 |
|
762 // ---------------------------------------------------------------------------- |
|
763 // CBlidLocation::CalculateTotalTimeL |
|
764 // ---------------------------------------------------------------------------- |
|
765 // |
|
766 void CBlidLocation::CalculateTotalTimeL() |
|
767 { |
|
768 TTime curTime; |
|
769 curTime.UniversalTime(); |
|
770 if( iIsTripStart ) |
|
771 { |
|
772 curTime.SecondsFrom(iInitViewTime,iTotalInterval); |
|
773 } |
|
774 } |
|
775 |
|
776 |
|
777 // ---------------------------------------------------------------------------- |
|
778 // CBlidLocation::UpdateTripData |
|
779 // ---------------------------------------------------------------------------- |
|
780 // |
|
781 void CBlidLocation::UpdateTripData( ) |
|
782 { |
|
783 if( iIsTripStart ) |
|
784 { |
|
785 TReal32 distance; |
|
786 TPosition& pos = GetCurrentPosition(); |
|
787 TReal32 max = Max(pos.HorizontalAccuracy(), iPrevPosition.HorizontalAccuracy()); |
|
788 |
|
789 if(iPrevPosition.Distance(pos, distance) == KErrNone) |
|
790 { |
|
791 TBool fixConsidered = EFalse; |
|
792 if( distance > max ) |
|
793 { |
|
794 iDistanceTravelled += distance; |
|
795 iTotalDistanceTravelled += distance; |
|
796 iPrevPosition = TPosition(pos); |
|
797 fixConsidered = ETrue; |
|
798 } |
|
799 else |
|
800 { |
|
801 TReal32 speed = iCourse.Speed(); |
|
802 if(speed > KBlidCutOffSpeed) |
|
803 { |
|
804 iDistanceTravelled += distance; |
|
805 iTotalDistanceTravelled += distance; |
|
806 iPrevPosition = TPosition(pos); |
|
807 fixConsidered = ETrue; |
|
808 } |
|
809 } |
|
810 if(fixConsidered) |
|
811 { |
|
812 // Evaluated Trip Speeds if fix considered |
|
813 TReal32 currentSpeed = iCourse.Speed(); |
|
814 if( currentSpeed > iTripMaxSpeed) |
|
815 { |
|
816 iTripMaxSpeed = currentSpeed; |
|
817 } |
|
818 |
|
819 TInt time = iTripInterval.Int(); |
|
820 iTripAverageSpeed = iDistanceTravelled / time; |
|
821 |
|
822 if(iTripAverageSpeed > iTripMaxSpeed) |
|
823 { |
|
824 iTripAverageSpeed = iTripMaxSpeed; |
|
825 } |
|
826 } |
|
827 } |
|
828 else |
|
829 { |
|
830 iDistanceTravelled = 0; |
|
831 iTotalDistanceTravelled = 0; |
|
832 } |
|
833 |
|
834 iIsDistanceTravelled = ETrue; |
|
835 } |
|
836 } |
|
837 |
|
838 // ---------------------------------------------------------------------------- |
|
839 // CBlidLocation::GetTripTime |
|
840 // ---------------------------------------------------------------------------- |
|
841 // |
|
842 void CBlidLocation::GetTripTime( TTimeIntervalSeconds& aTime ) |
|
843 { |
|
844 aTime = iTripInterval; |
|
845 } |
|
846 |
|
847 // ---------------------------------------------------------------------------- |
|
848 // CBlidLocation::GetTripTime |
|
849 // ---------------------------------------------------------------------------- |
|
850 // |
|
851 void CBlidLocation::GetTotalTime( TTimeIntervalSeconds& aTime ) |
|
852 { |
|
853 aTime = iTotalInterval; |
|
854 } |
|
855 |
|
856 // ---------------------------------------------------------------------------- |
|
857 // CBlidLocation::IsTripDistanceTravelled |
|
858 // ---------------------------------------------------------------------------- |
|
859 // |
|
860 TBool CBlidLocation::IsTripDistanceTravelled( ) |
|
861 { |
|
862 return iIsDistanceTravelled; |
|
863 } |
|
864 |
|
865 // ---------------------------------------------------------------------------- |
|
866 // CBlidLocation::GetTripDistance |
|
867 // ---------------------------------------------------------------------------- |
|
868 // |
|
869 void CBlidLocation::GetTripDistance(TReal32& aDistance ) |
|
870 { |
|
871 aDistance = iDistanceTravelled; |
|
872 } |
|
873 |
|
874 // ---------------------------------------------------------------------------- |
|
875 // CBlidLocation::GetTotalDistance |
|
876 // ---------------------------------------------------------------------------- |
|
877 // |
|
878 void CBlidLocation::GetTotalDistance(TReal32& aDistance ) |
|
879 { |
|
880 aDistance = iTotalDistanceTravelled; |
|
881 } |
|
882 |
|
883 // ---------------------------------------------------------------------------- |
|
884 // CBlidLocation::IsTotalDistanceTravelled |
|
885 // ---------------------------------------------------------------------------- |
|
886 // |
|
887 TBool CBlidLocation::IsTotalDistanceTravelled( ) |
|
888 { |
|
889 return iIsDistance; |
|
890 } |
|
891 |
|
892 // ---------------------------------------------------------------------------- |
|
893 // CBlidLocation::SetTripStartL |
|
894 // ---------------------------------------------------------------------------- |
|
895 // |
|
896 void CBlidLocation::SetTripStartL() |
|
897 { |
|
898 if( !iIsTripStart ) |
|
899 { |
|
900 iIsTripStart = ETrue; |
|
901 iIsTripNotStart = EFalse; |
|
902 iIsTripClear = EFalse; |
|
903 iInitTripTime.UniversalTime(); |
|
904 iInitViewTime.UniversalTime(); |
|
905 iDistanceTravelled = 0.0; |
|
906 if(iOnlineMode) |
|
907 { |
|
908 iPrevPosition = GetCurrentPosition(); |
|
909 iIsPreviousPositionUpdated = ETrue; |
|
910 } |
|
911 else |
|
912 { |
|
913 iIsPreviousPositionUpdated = EFalse; |
|
914 } |
|
915 |
|
916 if(iTimer) |
|
917 { |
|
918 delete iTimer; |
|
919 iTimer = NULL; |
|
920 } |
|
921 |
|
922 iTimer = CPeriodic::NewL(CActive::EPriorityHigh); |
|
923 TCallBack callback(TimerCallBackFunctionL, this); |
|
924 iTimer->Start( TTimeIntervalMicroSeconds32(1000000), |
|
925 TTimeIntervalMicroSeconds32(1000000), |
|
926 callback ); |
|
927 } |
|
928 } |
|
929 |
|
930 // ---------------------------------------------------------------------------- |
|
931 // CBlidLocation::HasTripStarted |
|
932 // ---------------------------------------------------------------------------- |
|
933 // |
|
934 TBool CBlidLocation::HasTripStarted() |
|
935 { |
|
936 return iIsTripStart; |
|
937 } |
|
938 |
|
939 // ---------------------------------------------------------------------------- |
|
940 // CBlidLocation::SetTripStop |
|
941 // ---------------------------------------------------------------------------- |
|
942 // |
|
943 void CBlidLocation::SetTripStop() |
|
944 { |
|
945 iIsTripStart = EFalse; |
|
946 //iIsTripNotStart = EFalse; |
|
947 if(iOnlineMode) |
|
948 { |
|
949 iWasGPSDataAvailableOnTripStop = ETrue; |
|
950 } |
|
951 else |
|
952 { |
|
953 iWasGPSDataAvailableOnTripStop = EFalse; |
|
954 } |
|
955 iStoppedTime.UniversalTime(); |
|
956 if(iTimer) |
|
957 { |
|
958 delete iTimer; |
|
959 iTimer = NULL; |
|
960 } |
|
961 } |
|
962 |
|
963 // ---------------------------------------------------------------------------- |
|
964 // CBlidLocation::HasTripStarted |
|
965 // ---------------------------------------------------------------------------- |
|
966 // |
|
967 TBool CBlidLocation::HasTripNotStarted() |
|
968 { |
|
969 return iIsTripNotStart; |
|
970 } |
|
971 |
|
972 // ---------------------------------------------------------------------------- |
|
973 // CBlidLocation::HasTripStarted |
|
974 // ---------------------------------------------------------------------------- |
|
975 // |
|
976 TBool CBlidLocation::WasGPSAvailableOnTripStop() |
|
977 { |
|
978 return iWasGPSDataAvailableOnTripStop; |
|
979 } |
|
980 |
|
981 // ---------------------------------------------------------------------------- |
|
982 // CBlidLocation::ResetTrip |
|
983 // ---------------------------------------------------------------------------- |
|
984 // |
|
985 void CBlidLocation::ResetTrip() |
|
986 { |
|
987 if(iIsTripStart == EFalse) |
|
988 { |
|
989 iIsTripReset = ETrue; |
|
990 } |
|
991 else |
|
992 { |
|
993 iIsTripReset = EFalse; |
|
994 } |
|
995 |
|
996 iDurationInSeconds = 0.0; |
|
997 iDistanceTravelled = 0.0; |
|
998 iTripTime = 0; |
|
999 iTripInterval = 0; |
|
1000 iInitTripTime.UniversalTime(); |
|
1001 iTripAverageSpeed = 0.0; |
|
1002 iTripMaxSpeed = 0.0; |
|
1003 } |
|
1004 |
|
1005 // ---------------------------------------------------------------------------- |
|
1006 // CBlidLocation::Restart |
|
1007 // ---------------------------------------------------------------------------- |
|
1008 // |
|
1009 /*void CBlidLocation::Restart() |
|
1010 { |
|
1011 iDurationInSeconds = 0.0; |
|
1012 iDistanceTravelled = 0.0; |
|
1013 //iTotalDistanceTravelled = 0.0; |
|
1014 iTotalDurationInSeconds = 0.0; |
|
1015 iWasGPSDataAvailableOnTripStop = EFalse; |
|
1016 iTripTime = 0; |
|
1017 iTotalTime = 0; |
|
1018 iTripInterval = 0; |
|
1019 iTotalInterval = 0; |
|
1020 iInitViewTime.UniversalTime(); |
|
1021 iInitTripTime.UniversalTime(); |
|
1022 iIsTripNotStart = EFalse; |
|
1023 iTripAverageSpeed = 0.0; |
|
1024 iTripMaxSpeed = 0.0; |
|
1025 }*/ |
|
1026 |
|
1027 // ---------------------------------------------------------------------------- |
|
1028 // CBlidLocation::SetTripResumeL |
|
1029 // ---------------------------------------------------------------------------- |
|
1030 // |
|
1031 void CBlidLocation::SetTripResumeL() |
|
1032 { |
|
1033 iIsTripStart = ETrue; |
|
1034 iIsTripNotStart = EFalse; |
|
1035 iWasGPSDataAvailableOnTripStop = EFalse; |
|
1036 iTimer = CPeriodic::NewL(CActive::EPriorityHigh); |
|
1037 TCallBack callback(TimerCallBackFunctionL, this); |
|
1038 iTimer->Start( TTimeIntervalMicroSeconds32(1000000), |
|
1039 TTimeIntervalMicroSeconds32(1000000), |
|
1040 callback ); |
|
1041 TTime curTime; |
|
1042 curTime.UniversalTime(); |
|
1043 TTimeIntervalMicroSeconds interval; |
|
1044 interval = curTime.MicroSecondsFrom(iStoppedTime); |
|
1045 |
|
1046 if(iStoppedTime > iInitViewTime ) |
|
1047 { |
|
1048 iInitViewTime = iInitViewTime + interval; |
|
1049 } |
|
1050 |
|
1051 if(iIsTripReset) |
|
1052 { |
|
1053 iInitTripTime.UniversalTime(); |
|
1054 iIsTripReset = EFalse; |
|
1055 } |
|
1056 else if(iStoppedTime > iInitTripTime ) |
|
1057 { |
|
1058 iInitTripTime = iInitTripTime + interval; |
|
1059 } |
|
1060 |
|
1061 if(iIsTripStart) |
|
1062 { |
|
1063 CalculateTripTimeL(); |
|
1064 } |
|
1065 CalculateTotalTimeL(); |
|
1066 |
|
1067 if(iObserver) |
|
1068 { |
|
1069 if(iOnlineMode) |
|
1070 { |
|
1071 iObserver->NotifyL(iOnlineMode); |
|
1072 } |
|
1073 else |
|
1074 { |
|
1075 iObserver->NotifyErrorL(KErrUnknown); |
|
1076 } |
|
1077 } |
|
1078 } |
|
1079 |
|
1080 // ---------------------------------------------------------------------------- |
|
1081 // CBlidLocation::SetTripClear |
|
1082 // ---------------------------------------------------------------------------- |
|
1083 // |
|
1084 void CBlidLocation::SetTripClear() |
|
1085 { |
|
1086 iIsTripClear = ETrue; |
|
1087 iIsTripStart = EFalse; |
|
1088 iIsTripReset = EFalse; |
|
1089 iIsDistance = ETrue; |
|
1090 iWasGPSDataAvailableOnTripStop = EFalse; |
|
1091 iTripAverageSpeed = 0.0; |
|
1092 iTripMaxSpeed = 0.0; |
|
1093 iTripGPSDataLost = EFalse; |
|
1094 iIsTripNotStart = ETrue; |
|
1095 |
|
1096 iDurationInSeconds = 0.0; |
|
1097 iDistanceTravelled = 0.0; |
|
1098 iTotalDurationInSeconds = 0.0; |
|
1099 iTripTime = 0; |
|
1100 iTotalTime = 0; |
|
1101 iTripInterval = 0; |
|
1102 iTotalInterval = 0; |
|
1103 iInitViewTime.UniversalTime(); |
|
1104 iInitTripTime.UniversalTime(); |
|
1105 } |
|
1106 |
|
1107 // ---------------------------------------------------------------------------- |
|
1108 // CBlidLocation::IsTripCleared |
|
1109 // ---------------------------------------------------------------------------- |
|
1110 // |
|
1111 TBool CBlidLocation::IsTripCleared() |
|
1112 { |
|
1113 return iIsTripClear; |
|
1114 } |
|
1115 |
|
1116 // ---------------------------------------------------------------------------- |
|
1117 // CBlidLocation::ResetTripClear |
|
1118 // ---------------------------------------------------------------------------- |
|
1119 // |
|
1120 void CBlidLocation::ResetTripClear() |
|
1121 { |
|
1122 iIsTripClear = EFalse; |
|
1123 iInitTripTime.UniversalTime(); |
|
1124 iInitViewTime.UniversalTime(); |
|
1125 } |
|
1126 |
|
1127 |
|
1128 // ---------------------------------------------------------------------------- |
|
1129 // CBlidLocation::ResetTripClear |
|
1130 // ---------------------------------------------------------------------------- |
|
1131 // |
|
1132 TBool CBlidLocation::IsTripReset() |
|
1133 { |
|
1134 return iIsTripReset; |
|
1135 } |
|
1136 |
|
1137 // ---------------------------------------------------------------------------- |
|
1138 // CBlidLocation::TimerCallBackL |
|
1139 // ---------------------------------------------------------------------------- |
|
1140 // |
|
1141 void CBlidLocation::TimerCallBackL() |
|
1142 { |
|
1143 if(iIsTripStart) |
|
1144 { |
|
1145 CalculateTripTimeL(); |
|
1146 } |
|
1147 CalculateTotalTimeL(); |
|
1148 |
|
1149 if(iObserver) |
|
1150 { |
|
1151 if(iOnlineMode) |
|
1152 { |
|
1153 iObserver->NotifyL(iOnlineMode); |
|
1154 } |
|
1155 else |
|
1156 { |
|
1157 iObserver->NotifyErrorL(KErrUnknown); |
|
1158 } |
|
1159 } |
|
1160 } |
|
1161 |
|
1162 // ---------------------------------------------------------------------------- |
|
1163 // CBlidLocation::GetHeading |
|
1164 // ---------------------------------------------------------------------------- |
|
1165 // |
|
1166 TReal32 CBlidLocation::GetHeading() |
|
1167 { |
|
1168 return iHeading; |
|
1169 } |
|
1170 |
|
1171 // ---------------------------------------------------------------------------- |
|
1172 // CBlidLocation::CalculateCourse |
|
1173 // ---------------------------------------------------------------------------- |
|
1174 // |
|
1175 void CBlidLocation::CalculateCourse() |
|
1176 { |
|
1177 TReal32 distance; |
|
1178 TPosition& pos = GetCurrentPosition(); |
|
1179 TReal32 max = Max(pos.HorizontalAccuracy(), iPrevPosition.HorizontalAccuracy()); |
|
1180 |
|
1181 if(iPrevCoursePosition.Distance(pos, distance) == KErrNone) |
|
1182 { |
|
1183 if( distance > 0.2 * max ) |
|
1184 { |
|
1185 iHeading = iCourse.Heading(); |
|
1186 iPrevCoursePosition = TPosition(pos); |
|
1187 } |
|
1188 } |
|
1189 else |
|
1190 { |
|
1191 iPrevCoursePosition = TPosition(pos); |
|
1192 } |
|
1193 } |
|
1194 |
|
1195 // ---------------------------------------------------------------------------- |
|
1196 // CBlidLocation::CheckGPSAvailability |
|
1197 // ---------------------------------------------------------------------------- |
|
1198 // |
|
1199 TInt CBlidLocation::CheckGPSAvailability() |
|
1200 { |
|
1201 TPositionModuleStatus lPosModuleStatus; |
|
1202 GetModuleInfoStatus(lPosModuleStatus); |
|
1203 TInt retVal = lPosModuleStatus.DeviceStatus(); |
|
1204 |
|
1205 |
|
1206 if ((retVal == TPositionModuleStatus::EDeviceError) || |
|
1207 (retVal == TPositionModuleStatus::EDeviceStandBy) || |
|
1208 (retVal == TPositionModuleStatus::EDeviceUnknown) ) |
|
1209 { |
|
1210 // GPS device unavailable |
|
1211 return 0; |
|
1212 } |
|
1213 else if( (retVal == TPositionModuleStatus::EDeviceReady) || |
|
1214 (retVal == TPositionModuleStatus::EDeviceActive) || |
|
1215 (retVal == TPositionModuleStatus::EDeviceInactive) ) |
|
1216 { |
|
1217 // GPS device is paired and available |
|
1218 return 1; |
|
1219 } |
|
1220 // GPS device connections is being established |
|
1221 return -1; |
|
1222 } |
|
1223 |
|
1224 // ---------------------------------------------------------------------------- |
|
1225 // CBlidLocation::IsGPSDataAvailable |
|
1226 // ---------------------------------------------------------------------------- |
|
1227 // |
|
1228 TBool CBlidLocation::IsGPSDataAvailable() |
|
1229 { |
|
1230 return iGPSDataAvailable; |
|
1231 } |
|
1232 |
|
1233 // ---------------------------------------------------------------------------- |
|
1234 // CBlidLocation::WasGPSDataLost |
|
1235 // ---------------------------------------------------------------------------- |
|
1236 // |
|
1237 TBool CBlidLocation::WasGPSDataLost() |
|
1238 { |
|
1239 return iTripGPSDataLost; |
|
1240 } |
|
1241 |
|
1242 // ---------------------------------------------------------------------------- |
|
1243 // CBlidLocation::SetGPSDataAvailability |
|
1244 // ---------------------------------------------------------------------------- |
|
1245 // |
|
1246 void CBlidLocation::SetGPSDataAvailability(TBool aAvailability) |
|
1247 { |
|
1248 iTripGPSDataLost = aAvailability; |
|
1249 } |
|
1250 |
|
1251 // ---------------------------------------------------------------------------- |
|
1252 // CBlidLocation::GetTripAverageSpeed |
|
1253 // ---------------------------------------------------------------------------- |
|
1254 // |
|
1255 TReal32 CBlidLocation::GetTripAverageSpeed() |
|
1256 { |
|
1257 return iTripAverageSpeed; |
|
1258 } |
|
1259 |
|
1260 // ---------------------------------------------------------------------------- |
|
1261 // CBlidLocation::GetTripAverageSpeed |
|
1262 // ---------------------------------------------------------------------------- |
|
1263 // |
|
1264 TReal32 CBlidLocation::GetTripMaxSpeed() |
|
1265 { |
|
1266 TReal32 currentSpeed = iCourse.Speed(); |
|
1267 return currentSpeed; |
|
1268 } |
|
1269 |
|
1270 // ---------------------------------------------------------------------------- |
|
1271 // CBlidLocation::GetModuleInfoNotification |
|
1272 // ---------------------------------------------------------------------------- |
|
1273 // |
|
1274 void CBlidLocation::GetModuleInfoNotificationL() |
|
1275 { |
|
1276 iModuleInfoArray.Reset(); |
|
1277 User::LeaveIfError( iServer.GetNumModules(iModuleCount) ); |
|
1278 TPositionModuleInfo moduleInfo; |
|
1279 |
|
1280 for( TUint i = 0; i < iModuleCount; i++ ) |
|
1281 { |
|
1282 User::LeaveIfError( iServer.GetModuleInfoByIndex( i, moduleInfo ) ); |
|
1283 iModuleInfoArray.Append(moduleInfo); |
|
1284 } |
|
1285 } |
|
1286 |
|
1287 // ---------------------------------------------------------------------------- |
|
1288 // CBlidLocation::SetNavigationStart |
|
1289 // ---------------------------------------------------------------------------- |
|
1290 // |
|
1291 void CBlidLocation::SetNavigationStart( TBool aNavigationStart ) |
|
1292 { |
|
1293 if( !aNavigationStart ) |
|
1294 { |
|
1295 iIsTripStart = EFalse; |
|
1296 } |
|
1297 else |
|
1298 { |
|
1299 iIsTripStart = ETrue; |
|
1300 } |
|
1301 |
|
1302 if( !iIsTripStart ) |
|
1303 { |
|
1304 // delete the timer because the stop trip will not be get called |
|
1305 // or else it will leads to memory leak |
|
1306 if(iTimer) |
|
1307 { |
|
1308 delete iTimer; |
|
1309 iTimer = NULL; |
|
1310 } |
|
1311 } |
|
1312 } |
|
1313 |
|
1314 // ---------------------------------------------------------------------------- |
|
1315 // CBlidLocation::ResetOdometerValue |
|
1316 // ---------------------------------------------------------------------------- |
|
1317 // |
|
1318 void CBlidLocation::ResetOdometerValue() |
|
1319 { |
|
1320 iTotalDistanceTravelled = 0.0; |
|
1321 } |
|
1322 |
|
1323 |
|
1324 // ---------------------------------------------------------------------------- |
|
1325 // CBlidLocation::IsSatCapablePsyAvailable |
|
1326 // ---------------------------------------------------------------------------- |
|
1327 // |
|
1328 TBool CBlidLocation::IsSatCapablePsyAvailable() |
|
1329 { |
|
1330 TUint numberOfModules; |
|
1331 TPositionModuleInfo moduleInfo; |
|
1332 numberOfModules = iModuleInfoArray.Count(); |
|
1333 |
|
1334 if( numberOfModules > 0) |
|
1335 { |
|
1336 moduleInfo = iModuleInfoArray[ 1 ]; |
|
1337 if ( (moduleInfo.Capabilities() & |
|
1338 TPositionModuleInfo::ECapabilitySatellite ) && |
|
1339 !moduleInfo.IsAvailable() ) |
|
1340 { |
|
1341 return ETrue; |
|
1342 } |
|
1343 } |
|
1344 return EFalse; |
|
1345 } |
|
1346 |
|
1347 // ---------------------------------------------------------------------------- |
|
1348 // CBlidLocation::NumberOfSatellitesVisible |
|
1349 // ---------------------------------------------------------------------------- |
|
1350 // |
|
1351 TInt CBlidLocation::NumberOfSatellitesVisible() |
|
1352 { |
|
1353 return iPositionInfo.NumSatellitesInView(); |
|
1354 } |
|
1355 |
|
1356 // ---------------------------------------------------------------------------- |
|
1357 // CBlidLocation::IsSatellitesUsed |
|
1358 // ---------------------------------------------------------------------------- |
|
1359 // |
|
1360 TBool CBlidLocation::IsSatellitesUsed( TInt aIndex ) |
|
1361 { |
|
1362 TBool lResult = EFalse; |
|
1363 TSatelliteData satData; |
|
1364 |
|
1365 if( GetSatelliteData( aIndex, satData ) != KErrNotFound) |
|
1366 { |
|
1367 lResult = satData.IsUsed(); |
|
1368 } |
|
1369 return lResult; |
|
1370 } |
|
1371 |
|
1372 // ---------------------------------------------------------------------------- |
|
1373 // CBlidLocation::SortSatelliteDataL |
|
1374 // ---------------------------------------------------------------------------- |
|
1375 // |
|
1376 void CBlidLocation::SortSatelliteDataL() |
|
1377 { |
|
1378 TSatelliteData tempSatelliteData; |
|
1379 TLinearOrder<TSatelliteData> order(SortCriteria); |
|
1380 iSortedSatData.Reset(); |
|
1381 TInt satellitesInView = iPositionInfo.NumSatellitesInView(); |
|
1382 for(TInt i = 0;i < satellitesInView ;i++ ) |
|
1383 { |
|
1384 User::LeaveIfError(iPositionInfo.GetSatelliteData(i,tempSatelliteData)); |
|
1385 TInt signalsth = tempSatelliteData.SignalStrength(); |
|
1386 iSortedSatData.InsertInOrderAllowRepeats(tempSatelliteData, order); |
|
1387 } |
|
1388 } |
|
1389 |
|
1390 // ---------------------------------------------------------------------------- |
|
1391 // CBlidLocation::GetSatelliteSignalStrength |
|
1392 // ---------------------------------------------------------------------------- |
|
1393 // |
|
1394 TInt CBlidLocation::GetSatelliteSignalStrength( TInt aIndex ) |
|
1395 { |
|
1396 TSatelliteData satData; |
|
1397 |
|
1398 if( GetSatelliteData( aIndex, satData ) != KErrNotFound ) |
|
1399 { |
|
1400 if( satData.SignalStrength() < KMinSatelliteSignalStrength ) |
|
1401 { |
|
1402 return 0; |
|
1403 } |
|
1404 else if( satData.SignalStrength() == KMinSatelliteSignalStrength ) |
|
1405 { |
|
1406 return 1; |
|
1407 } |
|
1408 else if( satData.SignalStrength() > KMinSatelliteSignalStrength && |
|
1409 satData.SignalStrength() < KMidSatelliteSignalStrength ) |
|
1410 { |
|
1411 return 2; |
|
1412 } |
|
1413 else if( satData.SignalStrength() > KMidSatelliteSignalStrength && |
|
1414 satData.SignalStrength() < KMaxSatelliteSignalStrength ) |
|
1415 { |
|
1416 return 3; |
|
1417 } |
|
1418 else if( satData.SignalStrength() > KMaxSatelliteSignalStrength ) |
|
1419 { |
|
1420 return 4; |
|
1421 } |
|
1422 } |
|
1423 return 0; |
|
1424 } |
|
1425 |
|
1426 // ---------------------------------------------------------------------------- |
|
1427 // CBlidLocation::GetSatelliteData |
|
1428 // ---------------------------------------------------------------------------- |
|
1429 // |
|
1430 TInt CBlidLocation::GetSatelliteData( TUint aIndex, |
|
1431 TSatelliteData& aSatelliteData) |
|
1432 { |
|
1433 if( aIndex >= iSortedSatData.Count() ) |
|
1434 { |
|
1435 return KErrNotFound; |
|
1436 } |
|
1437 aSatelliteData = iSortedSatData[aIndex]; |
|
1438 return KErrNone; |
|
1439 } |
|
1440 |
|
1441 // ---------------------------------------------------------------------------- |
|
1442 // CBlidLocation::GetSatelliteNo |
|
1443 // ---------------------------------------------------------------------------- |
|
1444 // |
|
1445 TInt CBlidLocation::GetSatelliteNo( TInt aIndex ) |
|
1446 { |
|
1447 TSatelliteData satData; |
|
1448 |
|
1449 if( GetSatelliteData( aIndex, satData ) != KErrNotFound) |
|
1450 { |
|
1451 return satData.SatelliteId(); |
|
1452 } |
|
1453 return 0; |
|
1454 } |
|
1455 |
|
1456 // ---------------------------------------------------------------------------- |
|
1457 // SortCriteria |
|
1458 // ---------------------------------------------------------------------------- |
|
1459 // |
|
1460 TInt SortCriteria(const TSatelliteData& aFirst, const TSatelliteData& aNext) |
|
1461 { |
|
1462 if(aFirst.SatelliteId() > aNext.SatelliteId()) |
|
1463 { |
|
1464 return 1; |
|
1465 } |
|
1466 else if(aFirst.SatelliteId() < aNext.SatelliteId()) |
|
1467 { |
|
1468 return -1; |
|
1469 } |
|
1470 return 0; |
|
1471 } |
|
1472 |
|
1473 // ---------------------------------------------------------------------------- |
|
1474 // TimerCallBackFunctionL |
|
1475 // ---------------------------------------------------------------------------- |
|
1476 // |
|
1477 TInt TimerCallBackFunctionL(TAny* aPtr) |
|
1478 { |
|
1479 CBlidLocation* ptr = static_cast<CBlidLocation*>(aPtr); |
|
1480 ptr->TimerCallBackL(); |
|
1481 return 1; |
|
1482 } |
|
1483 |
|
1484 // End of File |
|
1485 |