|
1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #include "ctlbsclientpostp2.h" |
|
21 #include "ctlbsclientpositionconstants.h" |
|
22 #include <LbsSatellite.h> |
|
23 |
|
24 // CONSTANTS |
|
25 |
|
26 // ================= MEMBER FUNCTIONS ======================= |
|
27 |
|
28 // --------------------------------------------------------- |
|
29 // Constructor. |
|
30 // --------------------------------------------------------- |
|
31 CT_LbsClientPosTp2::CT_LbsClientPosTp2(CT_LbsServer& aParent): CT_LbsPortedStepBase(aParent) |
|
32 { |
|
33 _LIT(KTestName, "TP2 - Request location from specific PSY"); |
|
34 SetTestStepName(KTestName); |
|
35 } |
|
36 |
|
37 // --------------------------------------------------------- |
|
38 // Destructor. |
|
39 // --------------------------------------------------------- |
|
40 CT_LbsClientPosTp2::~CT_LbsClientPosTp2() |
|
41 { |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------- |
|
45 // CT_LbsClientPosTp2::StartL |
|
46 // |
|
47 // (other items were commented in a header). |
|
48 // --------------------------------------------------------- |
|
49 // |
|
50 void CT_LbsClientPosTp2::StartL() |
|
51 { |
|
52 SetupPsyL(iUidMultiPsy); |
|
53 |
|
54 //synchronous request |
|
55 ConnectL(); |
|
56 |
|
57 User::LeaveIfError(OpenPositionerByName(iUidMultiPsy)); |
|
58 |
|
59 TPositionInfo info = TPositionInfo(); |
|
60 |
|
61 RequestL(info); |
|
62 CheckPositionInfoL(info); |
|
63 |
|
64 TPositionCourseInfo courseInfo; |
|
65 |
|
66 RequestL(courseInfo); |
|
67 CheckPositionCourseInfoL(courseInfo); |
|
68 |
|
69 TPositionSatelliteInfo satelliteInfo; |
|
70 |
|
71 RequestL(satelliteInfo); |
|
72 CheckPositionSatelliteInfoL(satelliteInfo); |
|
73 |
|
74 |
|
75 HPositionGenericInfo* genericInfo = HPositionGenericInfo::NewLC(); |
|
76 |
|
77 RequestL(*genericInfo); |
|
78 CheckGenericInfoL(*genericInfo); |
|
79 |
|
80 CleanupStack::PopAndDestroy(); //genericInfo |
|
81 |
|
82 ClosePositioner(); |
|
83 |
|
84 Disconnect(); |
|
85 } |
|
86 |
|
87 |
|
88 // --------------------------------------------------------- |
|
89 // CT_LbsClientPosTp2::AssertTrueL |
|
90 // |
|
91 // (other items were commented in a header). |
|
92 // --------------------------------------------------------- |
|
93 // |
|
94 void CT_LbsClientPosTp2::AssertTrueL(TBool aCondition, const TDesC& aErrorMsg) |
|
95 { |
|
96 if (!aCondition) |
|
97 { |
|
98 LogErrorAndLeaveL(aErrorMsg); |
|
99 } |
|
100 } |
|
101 |
|
102 void CT_LbsClientPosTp2::RequestL(TPositionInfoBase& aInfoBase) |
|
103 { |
|
104 _LIT(KService, "service"); |
|
105 TInt err = PerformSyncRequest(KService, &aInfoBase); |
|
106 |
|
107 if (err != KErrNone) |
|
108 { |
|
109 _LIT(KErrorRequest, "The request was not completed with KErrorNone, errCode = %d"); |
|
110 TBuf<100> buf; |
|
111 buf.Format(KErrorRequest, err); |
|
112 LogErrorAndLeaveL(buf); |
|
113 } |
|
114 |
|
115 _LIT(KIncorrectPsySyncRequestError, |
|
116 "TP2. Position from wrong PSY received (sync request)."); |
|
117 AssertTrueL(iUidMultiPsy == aInfoBase.ModuleId(), KIncorrectPsySyncRequestError); |
|
118 } |
|
119 |
|
120 void CT_LbsClientPosTp2::CheckPositionInfoL(TPositionInfo& aInfo) |
|
121 { |
|
122 TPosition pos; |
|
123 aInfo.GetPosition(pos); |
|
124 CheckPositionL(pos); |
|
125 } |
|
126 |
|
127 void CT_LbsClientPosTp2::CheckPositionCourseInfoL(TPositionCourseInfo& aCourseInfo) |
|
128 { |
|
129 CheckPositionInfoL(aCourseInfo); |
|
130 TCourse course; |
|
131 aCourseInfo.GetCourse(course); |
|
132 if (course.Heading() != KHeading || |
|
133 course.Speed() != KSpeed || |
|
134 course.SpeedAccuracy() != KSpeedAcc || |
|
135 course.HeadingAccuracy() != KHeadingAcc ) |
|
136 { |
|
137 _LIT(KErrCourse, "Course not correct"); |
|
138 LogErrorAndLeaveL(KErrCourse); |
|
139 } |
|
140 } |
|
141 |
|
142 void CT_LbsClientPosTp2::CheckPositionSatelliteInfoL(TPositionSatelliteInfo& aSatelliteInfo) |
|
143 { |
|
144 CheckPositionCourseInfoL(aSatelliteInfo); |
|
145 if((TUint)aSatelliteInfo.NumSatellitesUsed() != KNumberOfSatellitesUsed || |
|
146 aSatelliteInfo.SatelliteTime() != TTime(KSatelliteTime) || |
|
147 (TUint)aSatelliteInfo.NumSatellitesInView() != KNumberOfSatellitesInView || |
|
148 aSatelliteInfo.HorizontalDoP() != KHorizontalDoPValue || |
|
149 aSatelliteInfo.VerticalDoP() != KVerticalDoPValue || |
|
150 aSatelliteInfo.TimeDoP() != KTimeDoPValue) |
|
151 { |
|
152 _LIT(KErrBasicSat, "Basic satellite information not correct"); |
|
153 LogErrorAndLeaveL(KErrBasicSat); |
|
154 } |
|
155 TInt sats = aSatelliteInfo.NumSatellitesInView(); |
|
156 for (int i = 0; i < sats; i++) |
|
157 { |
|
158 TSatelliteData satelliteData; |
|
159 TInt err = aSatelliteInfo.GetSatelliteData(i,satelliteData); |
|
160 if (err != KErrNone) |
|
161 { |
|
162 _LIT(KErrGetSat, "Not possible to get satellite data, error code = %d"); |
|
163 TBuf<100> buf; |
|
164 buf.Format(KErrGetSat, err); |
|
165 LogErrorAndLeaveL(buf); |
|
166 } |
|
167 if ( (i%2) == 0 ) |
|
168 { |
|
169 if( satelliteData.SatelliteId() != (KSatelliteId +i) || |
|
170 satelliteData.Azimuth() != KAzimuth || |
|
171 satelliteData.Elevation() != KElevation || |
|
172 satelliteData.IsUsed() != KIsUsed || |
|
173 satelliteData.SignalStrength() != KSignalStrength) |
|
174 { |
|
175 _LIT(KErrSatDataEven, "Incorrect satellite data on even satellites"); |
|
176 LogErrorAndLeaveL(KErrSatDataEven); |
|
177 } |
|
178 } |
|
179 else |
|
180 { |
|
181 if( satelliteData.SatelliteId() != (KSatelliteId +i) || |
|
182 satelliteData.Azimuth() != KAzimuthOdd || |
|
183 satelliteData.Elevation() != KElevationOdd || |
|
184 satelliteData.IsUsed() != KIsUsedOdd || |
|
185 satelliteData.SignalStrength() != KSignalStrengthOdd) |
|
186 { |
|
187 _LIT(KErrSatDataOdd, "Incorrect satellite data on odd satellites"); |
|
188 LogErrorAndLeaveL(KErrSatDataOdd); |
|
189 } |
|
190 } |
|
191 |
|
192 } |
|
193 } |
|
194 |
|
195 void CT_LbsClientPosTp2::CheckGenericInfoL(HPositionGenericInfo& aGenericInfo) |
|
196 { |
|
197 CheckPositionInfoL(aGenericInfo); |
|
198 |
|
199 } |
|
200 |
|
201 void CT_LbsClientPosTp2::CheckPositionL(TPosition& aPos) |
|
202 { |
|
203 if (aPos.Time() != TTime(KPositionTime) || |
|
204 aPos.HorizontalAccuracy() != KHorizontalAcc || |
|
205 aPos.VerticalAccuracy() != KVerticalAcc || |
|
206 aPos.Latitude() != KLatitude || |
|
207 aPos.Longitude() != KLongitude || |
|
208 aPos.Altitude() != KAltitude) |
|
209 { |
|
210 _LIT(KErrPosition, "Wrong position returned"); |
|
211 LogErrorAndLeaveL(KErrPosition); |
|
212 } |
|
213 } |