locationtriggering/ltcellidmovementdetector/src/lbtcellidmvmtdet.cpp
branchRCL_3
changeset 21 6b6920c56e2f
parent 20 2b4ea9893b66
equal deleted inserted replaced
20:2b4ea9893b66 21:6b6920c56e2f
   237             else
   237             else
   238                 {
   238                 {
   239                 TReal ed = 0.0;
   239                 TReal ed = 0.0;
   240                 if( KErrNotFound != ComputeED( ed, cellInfo, iPrevCellInfo ) )
   240                 if( KErrNotFound != ComputeED( ed, cellInfo, iPrevCellInfo ) )
   241                     {
   241                     {
   242                     TInt error = iED.Append( ed );
   242                     iED.Append( ed );
   243                     if( error != KErrNone )
       
   244                         {
       
   245                         LOG1("Failed to append ed to the array:%d",error);
       
   246                         }
       
   247                     iSumOfED += ed;
   243                     iSumOfED += ed;
   248                     if( iED.Count() == 5 )
   244                     if( iED.Count() == 5 )
   249                         {
   245                         {
   250                         ComputeVarianceOfED();
   246                         ComputeVarianceOfED();
   251                         if( iAvgOfVariance > 5.0 )
   247                         if( iAvgOfVariance > 5.0 )
   375         {
   371         {
   376         LOG("Reason:1");
   372         LOG("Reason:1");
   377         return ETrue;
   373         return ETrue;
   378         }
   374         }
   379         
   375         
   380     TInt error = iSumOfSd.Append( sumOfSd );
   376     iSumOfSd.Append( sumOfSd );
   381     if( error != KErrNone )
   377     iVarianceOfRssi.Append( aCarrierRSSISD );
   382         {
       
   383         LOG1("Append sumOfSd to the array:%d",error);
       
   384         }
       
   385     error = iVarianceOfRssi.Append( aCarrierRSSISD );
       
   386     if( error != KErrNone )
       
   387         {
       
   388         LOG1("Append aCarrierRSSISD to the array:%d",error);
       
   389         }
       
   390     if( iSumOfSd.Count() == 3 )
   378     if( iSumOfSd.Count() == 3 )
   391         {
   379         {
   392         TReal sumAvg = 0.0;
   380         TReal sumAvg = 0.0;
   393         TReal rssiAvg = 0.0;
   381         TReal rssiAvg = 0.0;
   394         for( TInt i=0;i<iSumOfSd.Count();i++ )
   382         for( TInt i=0;i<iSumOfSd.Count();i++ )
   499             {
   487             {
   500             // Calculate difference in RxLEV and the corresponding square
   488             // Calculate difference in RxLEV and the corresponding square
   501             TInt diff = 
   489             TInt diff = 
   502                 ( ( aPrevCellInfo->GetNMR() )[pos].RxLEV ) - ( nmr.RxLEV );
   490                 ( ( aPrevCellInfo->GetNMR() )[pos].RxLEV ) - ( nmr.RxLEV );
   503             Math::Pow( diffSqr, diff, 2 );
   491             Math::Pow( diffSqr, diff, 2 );
   504             TInt error = diffArray.Append( diffSqr );
   492             diffArray.Append( diffSqr );
   505             if( error != KErrNone )
   493             posArray.Append( pos );
   506                 {
       
   507                 LOG1("Failed to append to diff array:%d",error);
       
   508                 }
       
   509             error = posArray.Append( pos );
       
   510             if( error !=KErrNone )
       
   511                 {
       
   512                 LOG1("Failed to append to pos array:%d",error);
       
   513                 }
       
   514             }
   494             }
   515         else
   495         else
   516             {
   496             {
   517             TInt diff = nmr.RxLEV - leastRxLEV;
   497             TInt diff = nmr.RxLEV - leastRxLEV;
   518             Math::Pow( diffSqr, diff, 2 );
   498             Math::Pow( diffSqr, diff, 2 );
   574         sum += sqr;
   554         sum += sqr;
   575         }
   555         }
   576 
   556 
   577     iED.Reset();
   557     iED.Reset();
   578     TReal variance = sum / 5;
   558     TReal variance = sum / 5;
   579     TInt error = iVarianceOfED.Append( variance );
   559     iVarianceOfED.Append( variance );
   580     if( error != KErrNone )
       
   581         {
       
   582         LOG1("Failed to append variance:%d",error);
       
   583         }
       
   584     
       
   585     
   560     
   586     // Check if variance is > 5. If true then check the next set of
   561     // Check if variance is > 5. If true then check the next set of
   587     // 5 variances. If there are more than two variance readings > 5
   562     // 5 variances. If there are more than two variance readings > 5
   588     // then compute average of the 5 readings and check if this value
   563     // then compute average of the 5 readings and check if this value
   589     // is > 5. If true then notify movement.
   564     // is > 5. If true then notify movement.