|
1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef TPOSDATASIMULATOR_H |
|
21 #define TPOSDATASIMULATOR_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <badesca.h> |
|
25 |
|
26 // FORWARD DECLARATIONS |
|
27 class TDesTokeniser; |
|
28 class TPositionInfo; |
|
29 |
|
30 // CLASS DECLARATION |
|
31 |
|
32 /** |
|
33 * A helper class for simulation of position info. |
|
34 */ |
|
35 class TPosDataSimulator |
|
36 { |
|
37 |
|
38 public: // Constructor |
|
39 |
|
40 /** |
|
41 * C++ default constructor. |
|
42 */ |
|
43 TPosDataSimulator(); |
|
44 |
|
45 public: // New functions |
|
46 |
|
47 /** |
|
48 * Computes a new position.. |
|
49 * |
|
50 * @param aPosition reference to a position pointer. |
|
51 * @param aRequestStartTime the request start-time |
|
52 * @param aLastRequestTime the last request time |
|
53 * |
|
54 * @return KErrNone if the new position computed successfully, |
|
55 * otherwise another of the system-wide error codes. |
|
56 */ |
|
57 TInt ComputeNewPositionL( |
|
58 /* OUT */ TPosition& aPosition, |
|
59 /* IN */ const TTime& aRequestStartTime, |
|
60 /* IN */ const TTime& aLastRequestTime |
|
61 ); |
|
62 |
|
63 /** |
|
64 * Parses and creates a position object. |
|
65 * |
|
66 * @param aPosition reference to a position pointer. This |
|
67 * pointer must be in scope until the request |
|
68 * has completed. |
|
69 * @param aDataArray an array containing simulation data |
|
70 * |
|
71 */ |
|
72 void ParseAndCreatePosObjectL( |
|
73 /* OUT */ TPosition& aPosition, |
|
74 /* IN */ const CDesC8Array* aDataArray |
|
75 ); |
|
76 |
|
77 /** |
|
78 * Computes a delay based on the request start time, min TTF and max TTF. |
|
79 * |
|
80 * @param aRequstStartTime the request start time. |
|
81 * |
|
82 * @return time to wait in microseconds. |
|
83 */ |
|
84 TTimeIntervalMicroSeconds TimeToWait( |
|
85 /* IN */ const TTime& aRequestStartTime |
|
86 ); |
|
87 |
|
88 /** |
|
89 * Checks if the request should fail or not. |
|
90 * |
|
91 * @param aNumberOfRequests the number of requests received so far. |
|
92 * @return KErrNone if function executed successfully, |
|
93 * KErrGeneral otherwise. |
|
94 */ |
|
95 TInt FailThisRequest( |
|
96 /* IN */ TInt aNumberOfRequests |
|
97 ); |
|
98 |
|
99 /** |
|
100 * Computes the power-up time. |
|
101 * @return TTimeIntervalMicroSeconds The powerup time. |
|
102 */ |
|
103 TTimeIntervalMicroSeconds PowerupTime(); |
|
104 |
|
105 private: // New functions |
|
106 |
|
107 /** |
|
108 * Calculates a random error. |
|
109 * |
|
110 * @return the calculated random error |
|
111 */ |
|
112 TReal GetRandomError(); |
|
113 |
|
114 /** |
|
115 * Adds random error to latitude, longitude, and altitude. |
|
116 */ |
|
117 void ComputeNewErrorForLatLonAltL( |
|
118 /* IN */ TReal& aFromLatitude, |
|
119 /* IN */ TReal& aFromLongitude, |
|
120 /* OUT */ TReal& aToLatitude, |
|
121 /* OUT */ TReal& aToLongitude |
|
122 ); |
|
123 |
|
124 /** |
|
125 * Converts a descriptor to an int. |
|
126 * |
|
127 * @param the descriptor to convert |
|
128 * @return the TInt |
|
129 */ |
|
130 TInt DesToIntL(const TDesC8& aDes); |
|
131 |
|
132 /** |
|
133 * Converts a descriptor to a real number. |
|
134 * |
|
135 * @param aDes the descriptor to convert |
|
136 * @return the real number |
|
137 */ |
|
138 TReal DesToRealL(const TDesC8& aDes); |
|
139 |
|
140 /** |
|
141 * Converts a descriptor to a real 32 bit number. |
|
142 * |
|
143 * @param aDes the descriptor to convert |
|
144 * @return the real 32 bit number |
|
145 */ |
|
146 TReal32 DesToFloatL(const TDesC8& aDes); |
|
147 |
|
148 /** |
|
149 * Checks if a int value is negative. If the value is |
|
150 * negative the function will leave. |
|
151 * |
|
152 * @param aDes the descriptor to check |
|
153 */ |
|
154 void LeaveIfNegativeIntL(const TDesC8& aDes); |
|
155 |
|
156 /** |
|
157 * Checks if a real value is negative. If the value is |
|
158 * negative the function will leave. |
|
159 * |
|
160 * @param aDes the descriptor to check |
|
161 */ |
|
162 void LeaveIfNegativeRealL(const TDesC8& aDes); |
|
163 |
|
164 /** |
|
165 * Checks whether the supplied latitude/longitude is correct. |
|
166 * The latitude should be between -aMinMaxValue and aMinMaxValue |
|
167 * |
|
168 * @param aDes the descriptor to check |
|
169 */ |
|
170 void CheckLatLonBoundariesL(const TDesC8& aDes, TReal aMinMaxValue); |
|
171 |
|
172 /** |
|
173 * Checks whether the supplied lexer is End of Stream or not. |
|
174 * |
|
175 * @param aLexer the lexer to check |
|
176 */ |
|
177 void CheckEosL(TLex8& aLexer); |
|
178 |
|
179 /** |
|
180 * Checks whether the supplied course is correct. |
|
181 * The latitude should be between 0 and 360 |
|
182 * |
|
183 * @param aDes the descriptor to check |
|
184 */ |
|
185 void CheckCourseBoundariesL(const TDesC8& aDes); |
|
186 |
|
187 /** |
|
188 * Checks if the argument is a value between -1 and +1. |
|
189 * |
|
190 * @param aCosArg the argument of the arccos function |
|
191 */ |
|
192 void ModifyCosArgIfNeeded(TReal& aCosArg); |
|
193 |
|
194 /** |
|
195 * Checks that the longitude is between 0 and 360. |
|
196 * |
|
197 * @param aLong The longitude to check |
|
198 */ |
|
199 void LongitudeBoundsCheck(TReal& aLong); |
|
200 |
|
201 private: |
|
202 TReal32 iHAcc; |
|
203 TReal32 iVAcc; |
|
204 |
|
205 TReal iLonErrorRadius; |
|
206 TReal iLatErrorRadius; |
|
207 TReal iErrorAngle; |
|
208 TReal32 iSpeed; |
|
209 TReal32 iTrueCourse; |
|
210 |
|
211 TReal iOrigLatitude; |
|
212 TReal iOrigLongitude; |
|
213 TReal iLatitude; |
|
214 TReal iLongitude; |
|
215 |
|
216 TReal32 iAltError; |
|
217 |
|
218 TInt iPowerupTime; |
|
219 TBool iRandomMode; |
|
220 TInt iTTFMin; |
|
221 TInt iTTFMax; |
|
222 TInt iFailFrequency; |
|
223 TInt iRandomTTF; |
|
224 TInt64 iSeed; |
|
225 }; |
|
226 |
|
227 #endif // TPOSDATASIMULATOR_H |
|
228 |
|
229 // End of File |