19 #include <liwvariant.h> |
19 #include <liwvariant.h> |
20 #include <liwgenericparam.h> |
20 #include <liwgenericparam.h> |
21 #include <liwcommon.h> |
21 #include <liwcommon.h> |
22 #include <sensrvchannelinfo.h> |
22 #include <sensrvchannelinfo.h> |
23 #include <sensrvtypes.h> |
23 #include <sensrvtypes.h> |
24 |
24 #include<e32math.h> |
25 // User Includes |
25 // User Includes |
26 #include "sensorservice.h" |
26 #include "sensorservice.h" |
27 #include "sensorinterface.h" |
27 #include "sensorinterface.h" |
28 #include "sensorservice.hrh" |
28 #include "sensorservice.hrh" |
29 #include "sensorcallback.h" |
29 #include "sensorcallback.h" |
480 CleanupStack::Pop( outMap ); |
480 CleanupStack::Pop( outMap ); |
481 CleanupStack::PopAndDestroy( &propertyList ); |
481 CleanupStack::PopAndDestroy( &propertyList ); |
482 outMap->DecRef(); |
482 outMap->DecRef(); |
483 |
483 |
484 }//end of GetChannelProperty |
484 }//end of GetChannelProperty |
|
485 else if( ( aCmdName.CompareF( KCmdGetScaleFactor ) == 0 ) ) |
|
486 { |
|
487 if( aCallback ) |
|
488 { |
|
489 iErrorString = KErrSensorInvalidReq.operator()().Alloc(); |
|
490 User::Leave( SErrInvalidServiceArgument ); |
|
491 } |
|
492 const TLiwGenericParam* channelInfoParam = NULL; |
|
493 channelInfoParam = aInParamList.FindFirst( position, KChnlInfoMap ); |
|
494 if ( !channelInfoParam ) |
|
495 { |
|
496 //Position based parsing |
|
497 if( aInParamList.Count() != 0 ) |
|
498 { |
|
499 channelInfoParam = &aInParamList[EParamIndex0]; |
|
500 } |
|
501 else |
|
502 { |
|
503 iErrorString = KErrMissingChnlMap.operator()().Alloc(); |
|
504 User::Leave( SErrMissingArgument ); |
|
505 } |
|
506 } |
|
507 CheckInputTypeL( &channelInfoParam->Value(), |
|
508 LIW::EVariantTypeMap, |
|
509 KChnlInfoMap.operator&() ); |
|
510 |
|
511 TSensrvChannelInfo channelInfo; |
|
512 const CLiwMap* chnlInfoMap = ( channelInfoParam->Value() ).AsMap(); |
|
513 //Retreive Channel Info |
|
514 GetChannelInfoL( channelInfo , chnlInfoMap ); |
|
515 |
|
516 TSensrvProperty measureProperty; |
|
517 TSensrvProperty scaleProperty; |
|
518 TRAPD(anErr,iSensorService->GetScaleFactorL( channelInfo , |
|
519 measureProperty,scaleProperty )); |
|
520 |
|
521 if( anErr != KErrNone ) |
|
522 { |
|
523 iErrorString = KErrInvalidChnlMap.operator()().Alloc(); |
|
524 User::Leave(KErrArgument); |
|
525 } |
|
526 TReal scaleFactor ; |
|
527 TReal measureValue; |
|
528 TInt scaleValue; |
|
529 measureProperty.GetValue( measureValue );// 0 or 1 |
|
530 scaleProperty.GetValue( scaleValue); // 8 or 12 |
|
531 TReal outputValue; |
|
532 TInt errPow; |
|
533 errPow = Math::Pow(outputValue,2,scaleValue-1); |
|
534 if( errPow == KErrNone ) |
|
535 { |
|
536 if( measureValue == 0 ) |
|
537 { |
|
538 scaleFactor = (2*9.8)/outputValue; |
|
539 aOutParamList.AppendL( TLiwGenericParam( KReturnValue , |
|
540 TLiwVariant( scaleFactor ) ) ); |
|
541 } |
|
542 else if(measureValue == 1) |
|
543 { |
|
544 scaleFactor = (8*9.8)/outputValue; |
|
545 aOutParamList.AppendL( TLiwGenericParam( KReturnValue , |
|
546 TLiwVariant( scaleFactor ) ) ); |
|
547 } |
|
548 else |
|
549 { |
|
550 iErrorString = KErrInvalidMeasureRange.operator()().Alloc(); |
|
551 User::Leave(KErrArgument); |
|
552 } |
|
553 } |
|
554 else |
|
555 { |
|
556 iErrorString = KErrInvalidPowValue.operator()().Alloc(); |
|
557 User::Leave(KErrArgument); |
|
558 } |
|
559 |
|
560 }//end of GetScaleFactor |
485 else |
561 else |
486 { |
562 { |
487 iErrorString = KErrSensorInvalidCmd.operator()().Alloc(); |
563 iErrorString = KErrSensorInvalidCmd.operator()().Alloc(); |
488 User::Leave( KErrNotSupported ); |
564 User::Leave( KErrNotSupported ); |
489 } |
565 } |