151 prop.SetArrayIndex(aArrayIndex); |
152 prop.SetArrayIndex(aArrayIndex); |
152 //Setting the property |
153 //Setting the property |
153 return iBackendData.iSensorChannel->SetProperty(prop); |
154 return iBackendData.iSensorChannel->SetProperty(prop); |
154 } |
155 } |
155 |
156 |
|
157 TSensrvPropertyType CSensorBackendSym::propertyType(TSensrvPropertyId aPropertyId, TInt &errId) |
|
158 { |
|
159 TSensrvProperty propertyType; |
|
160 //Getting the property to check the type |
|
161 TRAPD(err, iBackendData.iSensorChannel->GetPropertyL(aPropertyId, ESensrvSingleProperty, propertyType)); |
|
162 if(err != KErrNone) |
|
163 { |
|
164 errId = err; |
|
165 } |
|
166 //Find the type of property |
|
167 return propertyType.PropertyType(); |
|
168 } |
|
169 |
156 TInt CSensorBackendSym::SetMeasurementRange() |
170 TInt CSensorBackendSym::SetMeasurementRange() |
157 { |
171 { |
158 //Setting measurement range |
172 //Setting measurement range |
159 //Check if more than one output ranges are available |
173 //Check if more than one output ranges are available |
160 if(sensor()->outputRanges().length() <= 1) |
174 if(sensor()->outputRanges().length() <= 1) |
161 { |
175 { |
162 return KErrNone; |
176 return KErrNone; |
163 } |
177 } |
164 TSensrvProperty propertyType; |
178 |
165 //Getting the property to check the type |
179 TInt err = KErrNone; |
166 TRAPD(err, iBackendData.iSensorChannel->GetPropertyL(KSensrvPropIdMeasureRange, ESensrvSingleProperty, propertyType)); |
180 TSensrvPropertyType type = propertyType(KSensrvPropIdMeasureRange, err); |
167 if(err != KErrNone) |
181 if(err != KErrNone) |
168 { |
182 { |
169 return err; |
183 return err; |
170 } |
184 } |
171 //Find the type of property |
|
172 TSensrvPropertyType type = propertyType.PropertyType(); |
|
173 //If type is integer |
185 //If type is integer |
174 if(type == ESensrvRealProperty) |
186 if(type == ESensrvRealProperty) |
175 { |
187 { |
176 return SetProperty(KSensrvPropIdMeasureRange, ESensrvRealProperty, ESensrvArrayPropertyInfo, sensor()->outputRange()); |
188 return SetProperty(KSensrvPropIdMeasureRange, ESensrvRealProperty, ESensrvArrayPropertyInfo, sensor()->outputRange()); |
177 } |
189 } |
178 //If type is real |
190 //If type is real |
179 if(type == ESensrvIntProperty) |
191 if(type == ESensrvIntProperty) |
180 { |
192 { |
181 return SetProperty(KSensrvPropIdMeasureRange, ESensrvIntProperty, ESensrvArrayPropertyInfo, sensor()->outputRange()); |
193 return SetProperty(KSensrvPropIdMeasureRange, ESensrvIntProperty, ESensrvArrayPropertyInfo, sensor()->outputRange()); |
182 } |
194 } |
|
195 return KErrNone; |
183 } |
196 } |
184 |
197 |
185 TInt CSensorBackendSym::SetDataRate() |
198 TInt CSensorBackendSym::SetDataRate() |
186 { |
199 { |
187 //Get available datarates |
200 //Get available datarates |
194 //In descrete ranges if only one available, no need to set that range |
207 //In descrete ranges if only one available, no need to set that range |
195 if(availableDataRates.length() <= 1) |
208 if(availableDataRates.length() <= 1) |
196 { |
209 { |
197 return KErrNone; |
210 return KErrNone; |
198 } |
211 } |
199 return SetProperty(KSensrvPropIdDataRate, ESensrvIntProperty,ESensrvArrayPropertyInfo, |
212 TInt err = KErrNone; |
200 availableDataRates.indexOf(qrange(sensor()->dataRate(),sensor()->dataRate()))); |
213 TSensrvPropertyType type = propertyType(KSensrvPropIdDataRate, err); |
|
214 if(err != KErrNone) |
|
215 { |
|
216 return err; |
|
217 } |
|
218 if(type == ESensrvIntProperty) |
|
219 { |
|
220 return SetProperty(KSensrvPropIdDataRate, ESensrvIntProperty, ESensrvArrayPropertyInfo, |
|
221 availableDataRates.indexOf(qrange(sensor()->dataRate(),sensor()->dataRate()))); |
|
222 } |
|
223 else if(type == ESensrvRealProperty) |
|
224 { |
|
225 return SetProperty(KSensrvPropIdDataRate, ESensrvRealProperty, ESensrvArrayPropertyInfo, |
|
226 availableDataRates.indexOf(qrange(sensor()->dataRate(),sensor()->dataRate()))); |
|
227 } |
201 } |
228 } |
202 else |
229 else |
203 { |
230 { |
204 // Uses range value |
231 TInt err = KErrNone; |
205 return SetProperty(KSensrvPropIdDataRate, ESensrvIntProperty, ESensrvSingleProperty, sensor()->dataRate()); |
232 TSensrvPropertyType type = propertyType(KSensrvPropIdDataRate, err); |
|
233 if(err != KErrNone) |
|
234 { |
|
235 return err; |
|
236 } |
|
237 if(type == ESensrvIntProperty) |
|
238 { |
|
239 // Uses range value |
|
240 return SetProperty(KSensrvPropIdDataRate, ESensrvIntProperty, ESensrvSingleProperty, sensor()->dataRate()); |
|
241 } |
|
242 else if(type == ESensrvRealProperty) |
|
243 { |
|
244 // Uses range value |
|
245 return SetProperty(KSensrvPropIdDataRate, ESensrvIntProperty, ESensrvSingleProperty, sensor()->dataRate()); |
|
246 } |
206 } |
247 } |
207 } |
248 } |
208 // No data rates available |
249 // No data rates available |
209 return KErrNone; |
250 return KErrNone; |
210 } |
251 } |
211 |
252 |
212 void CSensorBackendSym::SetProperties() |
253 void CSensorBackendSym::SetProperties() |
213 { |
254 { |
214 if(sensor()) |
255 if(sensor()->outputRange() != -1) |
215 { |
256 { |
216 //Set measurement range |
257 //Set measurement range |
217 TInt err = SetMeasurementRange(); |
258 TInt err = SetMeasurementRange(); |
218 if(err != KErrNone) |
259 if(err != KErrNone) |
219 { |
260 { |
220 sensorError(err); |
261 sensorError(err); |
221 } |
262 } |
|
263 } |
|
264 if(sensor()->dataRate() != 0) |
|
265 { |
222 //Set data rate |
266 //Set data rate |
223 err = SetDataRate(); |
267 TInt err = SetDataRate(); |
224 if(err != KErrNone) |
268 if(err != KErrNone) |
225 { |
269 { |
226 sensorError(err); |
270 sensorError(err); |
227 } |
271 } |
228 } |
272 } |
308 } |
352 } |
309 } |
353 } |
310 |
354 |
311 void CSensorBackendSym::GetDataRate() |
355 void CSensorBackendSym::GetDataRate() |
312 { |
356 { |
313 RSensrvPropertyList list; |
357 TSensrvProperty datarate_prop; |
314 TRAPD(err, iBackendData.iSensorChannel->GetAllPropertiesL(KSensrvPropIdDataRate, list)); |
358 TInt err; |
|
359 TRAP(err, iBackendData.iSensorChannel->GetPropertyL(KSensrvPropIdDataRate, KSensrvItemIndexNone, datarate_prop)); |
315 if(err == KErrNone) |
360 if(err == KErrNone) |
316 { |
361 { |
317 //if list has only one item then it is range of values and not descrete values, agreed with DS team |
362 if(datarate_prop.GetArrayIndex() == ESensrvSingleProperty) |
318 if(list.Count() == 1) |
363 { |
319 { |
364 TReal min, max, value; |
320 TInt min, max, value; |
365 if(datarate_prop.PropertyType() == ESensrvIntProperty) |
321 list[0].GetMinValue(min); |
366 { |
322 list[0].GetMaxValue(max); |
367 TInt intMin, intMax, intValue; |
|
368 datarate_prop.GetMinValue(intMin); |
|
369 datarate_prop.GetMaxValue(intMax); |
|
370 datarate_prop.GetValue(intValue); |
|
371 min = intMin; |
|
372 max = intMax; |
|
373 value = intValue; |
|
374 } |
|
375 else if(datarate_prop.PropertyType() == ESensrvRealProperty) |
|
376 { |
|
377 datarate_prop.GetMinValue(min); |
|
378 datarate_prop.GetMaxValue(max); |
|
379 datarate_prop.GetValue(value); |
|
380 } |
323 //Set datarate as range |
381 //Set datarate as range |
324 addDataRate(min, max); |
382 addDataRate(min, max); |
325 list[0].GetValue(value); |
383 } |
326 //Set current datarate as default |
|
327 sensor()->setDataRate(value); |
|
328 } |
|
329 //if list has more than one item, data rate will be having descrete values, agreed with DS team |
384 //if list has more than one item, data rate will be having descrete values, agreed with DS team |
330 else |
385 else if(datarate_prop.GetArrayIndex() == ESensrvArrayPropertyInfo) |
331 { |
386 { |
332 TInt datarate, index; |
387 TReal datarate; |
333 for(int i=0; i<list.Count(); i++) |
388 TInt min, max, index; |
|
389 datarate_prop.GetMinValue(min); |
|
390 datarate_prop.GetMaxValue(max); |
|
391 datarate_prop.GetValue(index); |
|
392 for(int i=min; i<=max; i++) |
334 { |
393 { |
335 if(list[i].GetArrayIndex() == ESensrvArrayPropertyInfo) |
394 TRAP(err, iBackendData.iSensorChannel->GetPropertyL(KSensrvPropIdDataRate, KSensrvItemIndexNone, i, datarate_prop)); |
|
395 if(err == KErrNone) |
336 { |
396 { |
337 //If array index is ESensrvArrayPropertyInfo, getting the value to get current datarate |
397 if(datarate_prop.PropertyType() == ESensrvIntProperty) |
338 list[i].GetValue(index); |
398 { |
339 list[index].GetValue(datarate); |
399 TInt intDatarate; |
340 //Setting current datarate as default |
400 datarate_prop.GetValue(intDatarate); |
341 sensor()->setDataRate(datarate); |
401 datarate = intDatarate; |
342 continue; |
402 } |
343 } |
403 else if(datarate_prop.PropertyType() == ESensrvRealProperty) |
344 list[i].GetValue(datarate); |
404 { |
345 addDataRate(datarate, datarate); |
405 datarate_prop.GetValue(datarate); |
|
406 } |
|
407 addDataRate(datarate, datarate); |
|
408 } |
346 } |
409 } |
347 } |
410 } |
348 } |
411 } |
349 } |
412 } |
350 |
413 |
360 n:n for each n measurement ranges and accuracies |
423 n:n for each n measurement ranges and accuracies |
361 KAccuracyInvalid : for each n+x measurement ranges |
424 KAccuracyInvalid : for each n+x measurement ranges |
362 */ |
425 */ |
363 TReal accuracy = 0; |
426 TReal accuracy = 0; |
364 RSensrvPropertyList accuracyList; |
427 RSensrvPropertyList accuracyList; |
365 RSensrvPropertyList list; |
|
366 TInt err; |
428 TInt err; |
367 TRAP(err, iBackendData.iSensorChannel->GetAllPropertiesL(KSensrvPropIdChannelAccuracy, accuracyList)); |
429 TRAP(err, iBackendData.iSensorChannel->GetAllPropertiesL(KSensrvPropIdChannelAccuracy, accuracyList)); |
368 if(err == KErrNone) |
430 if(err == KErrNone) |
369 { |
431 { |
|
432 // If only one accuracy value present set value to accuracy |
370 if(accuracyList.Count() == 1) |
433 if(accuracyList.Count() == 1) |
371 { |
434 { |
372 accuracyList[0].GetValue(accuracy); |
435 if(accuracyList[0].PropertyType() == ESensrvIntProperty) |
373 } |
436 { |
|
437 TInt intAccuracy; |
|
438 accuracyList[0].GetValue(intAccuracy); |
|
439 accuracy = intAccuracy; |
|
440 } |
|
441 else if(accuracyList[0].PropertyType() == ESensrvRealProperty) |
|
442 { |
|
443 accuracyList[0].GetValue(accuracy); |
|
444 } |
|
445 } |
|
446 // If more than one accuracy values present set accuracy to invalid |
374 else |
447 else |
375 { |
448 { |
376 accuracy = KAccuracyInvalid; |
449 accuracy = KAccuracyInvalid; |
377 } |
450 } |
378 } |
451 } |
379 |
452 |
|
453 //Scale |
|
454 TSensrvProperty scale_prop; |
|
455 TReal scale=1; |
|
456 TRAP(err, iBackendData.iSensorChannel->GetPropertyL(KSensrvPropIdChannelScale, KSensrvItemIndexNone, scale_prop)); |
|
457 if(err == KErrNone) |
|
458 { |
|
459 if(scale_prop.PropertyType() == ESensrvIntProperty) |
|
460 { |
|
461 TInt intScale; |
|
462 scale_prop.GetValue(intScale); |
|
463 scale = intScale; |
|
464 } |
|
465 else if(scale_prop.PropertyType() == ESensrvRealProperty) |
|
466 { |
|
467 scale_prop.GetValue(scale); |
|
468 } |
|
469 TReal scaleMultiplier; |
|
470 Math::Pow(scaleMultiplier, 10, scale); |
|
471 scale = scaleMultiplier; |
|
472 } |
|
473 |
380 //measurement minimum & maximum |
474 //measurement minimum & maximum |
381 list.Reset(); |
475 TSensrvProperty measurerange_prop; |
382 TRAP(err, iBackendData.iSensorChannel->GetAllPropertiesL(KSensrvPropIdMeasureRange, list)); |
476 TRAP(err, iBackendData.iSensorChannel->GetPropertyL(KSensrvPropIdMeasureRange, KSensrvItemIndexNone, measurerange_prop)); |
383 if(err == KErrNone) |
477 if(err == KErrNone) |
384 { |
478 { |
385 for(int i=0; i<list.Count(); i++) |
479 if(measurerange_prop.GetArrayIndex() == ESensrvSingleProperty) |
386 { |
480 { |
387 if(list[i].GetArrayIndex() == ESensrvArrayPropertyInfo) |
481 TReal measureMin, measureMax, value; |
388 { |
482 if(measurerange_prop.PropertyType() == ESensrvIntProperty) |
389 continue; |
483 { |
390 } |
484 TInt intMin, intMax; |
391 if(list[i].PropertyType() == ESensrvIntProperty ) |
485 measurerange_prop.GetMinValue(intMin); |
392 { |
486 measurerange_prop.GetMaxValue(intMax); |
393 TInt min, max; |
487 measureMin = intMin; |
394 list[i].GetMinValue(min); |
488 measureMax = intMax; |
395 list[i].GetMaxValue(max); |
489 } |
396 if(accuracy != KAccuracyInvalid) |
490 else if(measurerange_prop.PropertyType() == ESensrvRealProperty) |
|
491 { |
|
492 measurerange_prop.GetMinValue(measureMin); |
|
493 measurerange_prop.GetMaxValue(measureMax); |
|
494 } |
|
495 //Set output as range |
|
496 addOutputRange(measureMin*scale, measureMax*scale, accuracy); |
|
497 } |
|
498 //if list has more than one item, data rate will be having descrete values, agreed with DS team |
|
499 else if(measurerange_prop.GetArrayIndex() == ESensrvArrayPropertyInfo) |
|
500 { |
|
501 TReal measureMin, measureMax; |
|
502 TInt min, max, index; |
|
503 if(measurerange_prop.PropertyType() == ESensrvIntProperty) |
|
504 { |
|
505 measurerange_prop.GetMinValue(min); |
|
506 measurerange_prop.GetMaxValue(max); |
|
507 measurerange_prop.GetValue(index); |
|
508 } |
|
509 else if(measurerange_prop.PropertyType() == ESensrvRealProperty) |
|
510 { |
|
511 TReal realMin, realMax, realValue; |
|
512 measurerange_prop.GetMinValue(realMin); |
|
513 measurerange_prop.GetMaxValue(realMax); |
|
514 measurerange_prop.GetValue(realValue); |
|
515 min = realMin; |
|
516 max = realMax; |
|
517 index = realValue; |
|
518 } |
|
519 for(int i=min; i<=max; i++) |
|
520 { |
|
521 TRAP(err, iBackendData.iSensorChannel->GetPropertyL(KSensrvPropIdMeasureRange, KSensrvItemIndexNone, i, measurerange_prop)); |
|
522 if(err == KErrNone) |
397 { |
523 { |
398 addOutputRange(min, max, accuracy); |
524 if(measurerange_prop.PropertyType() == ESensrvIntProperty) |
399 } |
|
400 else |
|
401 { |
|
402 if(accuracyList.Count() > i) |
|
403 { |
525 { |
404 accuracyList[i].GetValue(accuracy); |
526 TInt intMeasureMin, intMeasureMax; |
405 addOutputRange(min, max, accuracy); |
527 measurerange_prop.GetMinValue(intMeasureMin); |
|
528 measurerange_prop.GetMaxValue(intMeasureMax); |
|
529 measureMin = intMeasureMin; |
|
530 measureMax = intMeasureMax; |
406 } |
531 } |
|
532 else if(measurerange_prop.PropertyType() == ESensrvRealProperty) |
|
533 { |
|
534 measurerange_prop.GetMinValue(measureMin); |
|
535 measurerange_prop.GetMaxValue(measureMax); |
|
536 } |
|
537 // If only one accuracy value is present set same accuracy for all |
|
538 if(accuracy != KAccuracyInvalid) |
|
539 { |
|
540 addOutputRange(measureMin*scale, measureMax*scale, accuracy); |
|
541 } |
|
542 // If more than one accuracy values are there then map them linearly |
407 else |
543 else |
408 { |
544 { |
409 addOutputRange(min, max, KAccuracyInvalid); |
545 if(accuracyList.Count() > (i - min)) |
410 } |
546 { |
411 } |
547 accuracyList[i].GetValue(accuracy); |
412 } |
548 addOutputRange(measureMin*scale, measureMax*scale, accuracy); |
413 else if(list[i].PropertyType() == ESensrvRealProperty ) |
549 } |
414 { |
550 else |
415 TReal min, max; |
551 { |
416 list[i].GetMinValue(min); |
552 // If less accuracy values are present than measurement ranges then |
417 list[i].GetMaxValue(max); |
553 // set invalid accuracy for rest of measument ranges |
418 if(accuracy != KAccuracyInvalid) |
554 addOutputRange(measureMin*scale, measureMax*scale, KAccuracyInvalid); |
419 { |
555 } |
420 addOutputRange(min, max, accuracy); |
|
421 } |
|
422 else |
|
423 { |
|
424 if(accuracyList.Count() > i) |
|
425 { |
|
426 accuracyList[i].GetValue(accuracy); |
|
427 addOutputRange(min, max, accuracy); |
|
428 } |
|
429 else |
|
430 { |
|
431 addOutputRange(min, max, KAccuracyInvalid); |
|
432 } |
556 } |
433 } |
557 } |
434 } |
558 } |
435 } |
559 } |
436 } |
560 } |