|
1 // Copyright (c) 2006-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 "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // @file ctlbsconfigreader.h |
|
15 // This is the header file which contains the ini file configuration reader classes |
|
16 // |
|
17 // |
|
18 |
|
19 #ifndef __CT_LBS_CONFIG_READER_H__ |
|
20 #define __CT_LBS_CONFIG_READER_H__ |
|
21 |
|
22 |
|
23 // Epoc includes |
|
24 #include <e32cmn.h> |
|
25 |
|
26 // LBS includes |
|
27 #include <lbs.h> |
|
28 #include <lbscommon.h> |
|
29 #include <lbspositioninfo.h> |
|
30 #include <lbs/lbslocdatasourcegpsbase.h> |
|
31 |
|
32 // LBS test includes |
|
33 #include <lbs/test/tlbsutils.h> |
|
34 |
|
35 // Forward Declaration |
|
36 |
|
37 |
|
38 |
|
39 const TInt KMaxSentence = 200; |
|
40 const TInt KMaxFields = 20; |
|
41 const TInt KMaxIniFileBuffer = 100; |
|
42 const TInt KMaxConfigReaderIniFileName = 100; |
|
43 |
|
44 class CConfigReaderBase : public CBase |
|
45 { |
|
46 public: |
|
47 virtual ~CConfigReaderBase(); |
|
48 |
|
49 /** Main entry function which reads the ini file, fills out the data items defined in the |
|
50 derived classes. Once NewL as been called to construct the object, this should then be |
|
51 called. */ |
|
52 void ProcessL(); |
|
53 |
|
54 protected: |
|
55 /** Converts a string to a TInt value. */ |
|
56 void ExtractValueL(const TPtrC8& aField, TInt& aValue); |
|
57 |
|
58 /** Converts a string to a TReal32 value. */ |
|
59 void ExtractValueL(const TPtrC8& aField, TReal32& aValue); |
|
60 |
|
61 /** Converts a string to a TReal64 value. */ |
|
62 void ExtractValueL(const TPtrC8& aField, TReal64& aValue); |
|
63 |
|
64 // void ExtractDegreesL(const TPtrC8& aField, TReal64& aDegrees); this maybe handy so we can have lat, long in degrees not raw real numbers... |
|
65 // void ExtractTimeL(const TPtrC8& aTime, TDateTime& aTheTime); |
|
66 // void ExtractDateL(const TPtrC8& aDate, TDateTime& aTheDate); |
|
67 |
|
68 // Derived classes provide the implementation. |
|
69 /** Parses a full sentence read from the ini file. */ |
|
70 virtual void HandleSentenceL()=0; |
|
71 |
|
72 /** Fills the data item (detailed in the derived class) with default values. */ |
|
73 virtual void DefaultData()=0; |
|
74 |
|
75 /** Fills the data item (detailed in the derived class) with values parsed from the sentence. */ |
|
76 virtual void ExtractDataL()=0; |
|
77 |
|
78 CConfigReaderBase(const TDesC &aConfigFileName); |
|
79 |
|
80 CConfigReaderBase(const TDesC& aConfigFileName, const TDesC& aConfigSection); |
|
81 |
|
82 private: |
|
83 /** Adds valid sentence character to the field. Once the field delimiter is found the field |
|
84 is appended to the field array. */ |
|
85 void AppendFieldChar(TUint aChar); |
|
86 |
|
87 /** Process sentences read from the ini file buffer. A complete valid sentence is passed |
|
88 to HandeSentenceL() to allow the derived class to process the sentence fields into |
|
89 it's data items. */ |
|
90 void ProcessStringL(const TDesC8& aData); |
|
91 |
|
92 private: |
|
93 // enum TReadState {EWantStart, EWantTerminator}; |
|
94 |
|
95 enum TReadState {/* EStart, */ |
|
96 EStartSection, |
|
97 EProcessSection, |
|
98 EStartSentence, |
|
99 EProcessSentence, |
|
100 EHalt}; |
|
101 |
|
102 |
|
103 //const TDesC iConfigFileName; // can we try this, but we will not be able to add the path |
|
104 /** Configuration ini filename to open and read. */ |
|
105 TBuf<KMaxConfigReaderIniFileName> iConfigFileName; |
|
106 TBuf<KMaxSentence> iConfigSection; |
|
107 |
|
108 /** State machine variable used while processing a sentence. */ |
|
109 TReadState iReadState; |
|
110 |
|
111 /** The sentence buffer, to store a valid sentence ready for processing. */ |
|
112 TBuf8<KMaxSentence> iSentence; |
|
113 |
|
114 |
|
115 TBuf8<KMaxSentence> iReadSection; |
|
116 |
|
117 protected: |
|
118 /** Field array. Each field is delimited by a ',' or '*' and will be converted into the |
|
119 member variable of the data item defined in the derived class. */ |
|
120 TPtrC8 iFields[KMaxFields]; |
|
121 |
|
122 /** Number of fields in the field array. */ |
|
123 TInt iNumFields; |
|
124 |
|
125 /** Where the field starts in the sentence string. */ |
|
126 TInt iFieldStart; |
|
127 |
|
128 /** Length of the field. */ |
|
129 TInt iFieldLength; |
|
130 }; |
|
131 |
|
132 |
|
133 |
|
134 // Default values for TPosition, |
|
135 #define DEFAULT_NOTIFY_POS_UPDATE_LATITUDE 49.2 |
|
136 #define DEFAULT_NOTIFY_POS_UPDATE_LONGITUDE 3.5 |
|
137 #define DEFAULT_NOTIFY_POS_UPDATE_ALTITUDE 50.0 |
|
138 #define DEFAULT_NOTIFY_POS_UPDATE_HORIZONTAL_ACCURACY 2.0 |
|
139 #define DEFAULT_NOTIFY_POS_UPDATE_VERTICAL_ACCURACY 3.0 |
|
140 |
|
141 // TCourse |
|
142 #define DEFAULT_NOTIFY_POS_UPDATE_SPEED 26.0 |
|
143 #define DEFAULT_NOTIFY_POS_UPDATE_HEADING 25.0 |
|
144 #define DEFAULT_NOTIFY_POS_UPDATE_VERTICAL_SPEED 20.0 |
|
145 #define DEFAULT_NOTIFY_POS_UPDATE_COURSE 30.0 |
|
146 #define DEFAULT_NOTIFY_POS_UPDATE_SPEED_ACCURACY 2.0 |
|
147 #define DEFAULT_NOTIFY_POS_UPDATE_HEADING_ACCURACY 10.0 |
|
148 #define DEFAULT_NOTIFY_POS_UPDATE_VERTICAL_SPEED_ACCURACY 3.0 |
|
149 #define DEFAULT_NOTIFY_POS_UPDATE_COURSE_ACCURACY 4.0 |
|
150 |
|
151 // TSatelliteData - first satellite |
|
152 #define DEFAULT_NOTIFY_POS_UPDATE_SATELLITE_ID1 10 |
|
153 #define DEFAULT_NOTIFY_POS_UPDATE_AZIMUTH1 50.0 |
|
154 #define DEFAULT_NOTIFY_POS_UPDATE_ELEVATION1 27.0 |
|
155 #define DEFAULT_NOTIFY_POS_UPDATE_IS_USED1 ETrue |
|
156 #define DEFAULT_NOTIFY_POS_UPDATE_SIGNAL_STRENGTH1 4 |
|
157 |
|
158 // TSatelliteData - second stellite |
|
159 #define DEFAULT_NOTIFY_POS_UPDATE_SATELLITE_ID2 11 |
|
160 #define DEFAULT_NOTIFY_POS_UPDATE_AZIMUTH2 47.0 |
|
161 #define DEFAULT_NOTIFY_POS_UPDATE_ELEVATION2 30.0 |
|
162 #define DEFAULT_NOTIFY_POS_UPDATE_IS_USED2 EFalse |
|
163 #define DEFAULT_NOTIFY_POS_UPDATE_SIGNAL_STRENGTH2 3 |
|
164 |
|
165 //TDetailedErrorReport |
|
166 #define DEFAULT_SD_OF_LONG_ERROR 5.0 |
|
167 #define DEFAULT_SD_OF_LAT_ERROR 6.0 |
|
168 #define DEFAULT_SD_OF_ALT_ERROR 7.0 |
|
169 #define DEFAULT_SD_OF_SEMI_MAJOR_AXIS_ERROR 8.0 |
|
170 #define DEFAULT_SD_OF_SEMI_MINOR_AXIS_ERROR 9.0 |
|
171 #define DEFAULT_ORIEN_OF_SEMI_MAJOR_AXIS_ERROR 10.0 |
|
172 #define DEFAULT_RMS_VAL_OF_SD_OF_RANGE 11.0 |
|
173 |
|
174 #define DEFAULT_GEOIDAL_SEPARATION 12.0 |
|
175 #define DEFAULT_MAGNETIC_VARIATION 13.0 |
|
176 #define DEFAULT_COURSE_OVER_GROUND_MAGNETIC 14.0 |
|
177 //TGpsTimingMeasurementData |
|
178 #define DEFAULT_GPS_TIMING_OF_CELL_MsPart 16383 |
|
179 #define DEFAULT_GPS_TIMING_OF_CELL_LsPart 4294967295UL |
|
180 #define DEFAULT_REFERENCE_IDENTITY 511 |
|
181 #define DEFAULT_SFN 4095 |
|
182 |
|
183 |
|
184 class CUpdateConfigReader : public CConfigReaderBase |
|
185 { |
|
186 public: |
|
187 |
|
188 enum TUpdateFields |
|
189 { |
|
190 EUpdateType = 0, // Must be present |
|
191 EUpdateRepeat, |
|
192 ENumOfMeasurements, |
|
193 |
|
194 // TCoordinate |
|
195 EPosLatitude, /** TCoordinate.iLatitude, TReal64 */ |
|
196 EPosLongitude, /** TCoordinate.iLongitude, TReal64 */ |
|
197 EPosAltitude, /** TCoordinate.iAltitude, TReal32 */ |
|
198 |
|
199 // TLocalitiy |
|
200 EPosHorzAccuracy, /** TLocality.iHorizontalAccuracy, TReal32 */ |
|
201 EPosVertAccuracy, /** TLocality.iVerticalAccuracy, TReal32 */ |
|
202 |
|
203 // Optional |
|
204 EUpdateErr, |
|
205 EUpdateDelay /** Time to delay, can be negative to force early update */ |
|
206 }; |
|
207 |
|
208 |
|
209 static CUpdateConfigReader* NewL(const TDesC &aConfigFileName, const TDesC& aConfigSection, RPointerArray<TLbsModuleUpdateItem>& aUpdateArr); |
|
210 |
|
211 protected: |
|
212 void HandleSentenceL(); |
|
213 |
|
214 void DefaultData(); |
|
215 void ExtractDataL(); |
|
216 |
|
217 private: |
|
218 CUpdateConfigReader(const TDesC &aConfigFileName, const TDesC& aConfigSection, RPointerArray<TLbsModuleUpdateItem>& aUpdateArr); |
|
219 void ConstructL(); |
|
220 |
|
221 RPointerArray<TLbsModuleUpdateItem>& iUpdateArr; |
|
222 TLbsModuleUpdateItem* iUpdate; |
|
223 }; |
|
224 |
|
225 |
|
226 |
|
227 |
|
228 class CPosInfoConfigReader : public CConfigReaderBase |
|
229 { |
|
230 public: |
|
231 |
|
232 enum TPosInfoFields |
|
233 { |
|
234 EPosType = 0, // Must be present |
|
235 EposRepeat, |
|
236 |
|
237 // TCoordinate |
|
238 EPosLatitude, /** TCoordinate.iLatitude, TReal64 */ |
|
239 EPosLongitude, /** TCoordinate.iLongitude, TReal64 */ |
|
240 EPosAltitude, /** TCoordinate.iAltitude, TReal32 */ |
|
241 EPosDatum, /** TCoordinate.iDatum, TUid */ |
|
242 |
|
243 // TLocalitiy |
|
244 EPosHorzAccuracy, /** TLocality.iHorizontalAccuracy, TReal32 */ |
|
245 EPosVertAccuracy, /** TLocality.iVerticalAccuracy, TReal32 */ |
|
246 |
|
247 // TPosition |
|
248 // EPosTime, /** TPosition.iTime, TTime */ // see comment below |
|
249 |
|
250 // TCourse |
|
251 EPosSpeed, /** TCourse.iSpeed, TReal32 */ |
|
252 EPosHeading, /** TCourse.iHeading, TReal32 */ |
|
253 EPosSpeedAccuracy, /** TCourse.iSpeedAccuracy, TReal32 */ |
|
254 EPosHeadingAccuracy, /** TCourse.iHeadingAccuracy, TReal32 */ |
|
255 }; |
|
256 |
|
257 |
|
258 static CPosInfoConfigReader* NewL(const TDesC &aConfigFileName, const TDesC& aConfigSection, RPointerArray<TAny>& aPosInfoArr); |
|
259 |
|
260 protected: |
|
261 void HandleSentenceL(); |
|
262 |
|
263 void DefaultData(); |
|
264 void ExtractDataL(); |
|
265 |
|
266 private: |
|
267 CPosInfoConfigReader(const TDesC &aConfigFileName, const TDesC& aConfigSection, RPointerArray<TAny>& aPosInfoArr); |
|
268 void ConstructL(); |
|
269 |
|
270 RPointerArray<TAny>& iPosInfoArr; |
|
271 TPositionInfoBase* iPosInfo; |
|
272 }; |
|
273 |
|
274 |
|
275 |
|
276 /** CModuleStatusConfigReader is a reader class to process module status sentences. |
|
277 Once processed the aModuleStatus item will be filled with field values held in |
|
278 the sentence. |
|
279 |
|
280 The supported sentence is "modstatus", which MUST start with '$' and end with '*', |
|
281 fields MUST be delimted by ',' and the sentence MUST NOT contain any white space. |
|
282 |
|
283 $modstatus,device_field,data_quality_field* |
|
284 |
|
285 where device_field is one of |
|
286 device_error |
|
287 device_disable |
|
288 device_inactive |
|
289 device_initialising |
|
290 device_standby |
|
291 device_ready |
|
292 device_active |
|
293 |
|
294 where data_quality_field is one of |
|
295 data_quality_loss |
|
296 data_quality_partial |
|
297 data_quality_normal |
|
298 |
|
299 */ |
|
300 class CModuleStatusConfigReader : public CConfigReaderBase |
|
301 { |
|
302 public: |
|
303 |
|
304 enum TModuleStatusFields |
|
305 { |
|
306 EModuleStatusType = 0, // Must be present, only 1 type 'modstatus'. |
|
307 |
|
308 // TPositionModuleStatus fields. |
|
309 EModuleStatusDevice, /** TPositionModuleStatus.iDeviceStatus, TDeviceStatus */ |
|
310 EModuleStatusDataQuality, /** TPositionModuleStatus.iDataQualityStatus, TDataQualityStatus */ |
|
311 EModuleStatusDelayUpdate /** */ |
|
312 }; |
|
313 |
|
314 static CModuleStatusConfigReader* NewL(const TDesC &aConfigFileName, const TDesC& aConfigSection, TPositionModuleStatus& aModuleStatus, TBool& aDelayReportingModStatus); |
|
315 |
|
316 protected: |
|
317 /** Converts a string to a TPositionModuleStatus::TDeviceStatus enum value. */ |
|
318 void ExtractValueDevice(const TPtrC8& aField, TPositionModuleStatus::TDeviceStatus& aValue); |
|
319 |
|
320 /** Converts a string to a TPositionModuleStatus::TDataQualityStatus enum value. */ |
|
321 void ExtractValueDataQuality(const TPtrC8& aField, TPositionModuleStatus::TDataQualityStatus& aValue); |
|
322 |
|
323 void ExtractValueDelayUpdate(const TPtrC8& aField, TBool& aValue); |
|
324 /** See CConfigReaderBase for comments. */ |
|
325 void HandleSentenceL(); |
|
326 void DefaultData(); |
|
327 void ExtractDataL(); |
|
328 |
|
329 private: |
|
330 CModuleStatusConfigReader(const TDesC &aConfigFileName, const TDesC& aConfigSection, TPositionModuleStatus& aModuleStatus, TBool& aDelayReportingModStatus); |
|
331 |
|
332 /** Reference to the module status data item to be setup. */ |
|
333 TPositionModuleStatus& iModuleStatus; |
|
334 /** */ |
|
335 TBool& iDelayReportingModStatus; |
|
336 }; |
|
337 |
|
338 |
|
339 |
|
340 /* and a class reader for module update options |
|
341 updateoptions,100,100,100,false |
|
342 interval, |
|
343 timeout |
|
344 maxage |
|
345 partialupdates |
|
346 */ |
|
347 |
|
348 class CUpdateOptsConfigReader : public CConfigReaderBase |
|
349 { |
|
350 public: |
|
351 |
|
352 enum TUpdateOptsFields |
|
353 { |
|
354 EUpdateOptsType = 0, // Must be present, only 1 type 'updateoptions' |
|
355 |
|
356 // TPositionUpdateOptions |
|
357 EUpdateOptsInterval, /** TPositionUpdateOptions.iUpdateInterval, TTimeIntervalMicroSeconds */ |
|
358 EUpdateOptsTimeOut, /** TPositionUpdateOptions.iUpdateTimeOut, TTimeIntervalMicroSeconds */ |
|
359 EUpdateOptsMaxAge, /** TPositionUpdateOptions.iMaxUpdateAge, TTimeIntervalMicroSeconds */ |
|
360 EUpdateOptsPartialUpdates /** TBool TPositionUpdateOptions.iAcceptPartialUpdates, TBool */ |
|
361 }; |
|
362 |
|
363 |
|
364 static CUpdateOptsConfigReader* NewL(const TDesC &aConfigFileName, const TDesC& aConfigSection, TPositionUpdateOptions& aUpdateOpts); |
|
365 |
|
366 protected: |
|
367 /** Converts string to a TTimeIntervalMicroSeconds value. */ |
|
368 void ExtractValueL(const TPtrC8& aField, TTimeIntervalMicroSeconds& aValue); |
|
369 |
|
370 /** Converts string to a TBool value. */ |
|
371 void ExtractValue(const TPtrC8& aField, TBool& aValue); |
|
372 |
|
373 void HandleSentenceL(); |
|
374 |
|
375 void DefaultData(); |
|
376 void ExtractDataL(); |
|
377 |
|
378 private: |
|
379 CUpdateOptsConfigReader(const TDesC &aConfigFileName, const TDesC& aConfigSection, TPositionUpdateOptions& aUpdateOpts); |
|
380 |
|
381 TPositionUpdateOptions& iUpdateOpts; |
|
382 }; |
|
383 |
|
384 /* |
|
385 * Class reader for the expected modes in which the module is asked to run |
|
386 */ |
|
387 class CAgpsModuleModesConfigReader : public CConfigReaderBase |
|
388 { |
|
389 private: |
|
390 enum TModuleModesFields |
|
391 { |
|
392 EModuleModesType = 0, // must be present and needs to be 'modulemodes' |
|
393 EGpsModeField, // the GPS mode |
|
394 EBegginingOfGpsOptionsArray // where the array of gps options items starts |
|
395 }; |
|
396 public: |
|
397 static CAgpsModuleModesConfigReader* NewL(const TDesC &aConfigFileName, const TDesC& aConfigSection, |
|
398 RPointerArray<TLbsGpsOptions>& aModuleModes); |
|
399 private: |
|
400 CAgpsModuleModesConfigReader(const TDesC &aConfigFileName, const TDesC& aConfigSection, |
|
401 RPointerArray<TLbsGpsOptions>& aModuleModes); |
|
402 void HandleSentenceL(); |
|
403 |
|
404 void DefaultData(); |
|
405 void ExtractDataL(); |
|
406 |
|
407 private: |
|
408 RPointerArray<TLbsGpsOptions>& iModuleModes; |
|
409 }; |
|
410 |
|
411 /* |
|
412 * Class reader for details of all clients making requests in a test |
|
413 */ |
|
414 class CClientDetailsConfigReader : public CConfigReaderBase |
|
415 { |
|
416 public: |
|
417 static CClientDetailsConfigReader* NewL(const TDesC &aConfigFileName, const TDesC& aConfigSection, |
|
418 RArray<TCTClientDetails>& aClientDetailsArray); |
|
419 private: |
|
420 CClientDetailsConfigReader(const TDesC &aConfigFileName, const TDesC& aConfigSection, |
|
421 RArray<TCTClientDetails>& aClientDetailsArray); |
|
422 void HandleSentenceL(); |
|
423 |
|
424 void DefaultData(); |
|
425 void ExtractDataL(); |
|
426 |
|
427 private: |
|
428 RArray<TCTClientDetails>& iClientDetailsArray; |
|
429 }; |
|
430 #endif //__CT_LBS_CONFIG_READER_H__ |