telephonyserverplugins/simatktsy/src/csattimer.cpp
branchRCL_3
changeset 66 07a122eea281
parent 65 630d2f34d719
equal deleted inserted replaced
65:630d2f34d719 66:07a122eea281
     1 // Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    18 //
    18 //
    19 
    19 
    20 
    20 
    21 
    21 
    22 //  INCLUDE FILES
    22 //  INCLUDE FILES
    23 
       
    24 #include "OstTraceDefinitions.h"
       
    25 #ifdef OST_TRACE_COMPILER_IN_USE
       
    26 #include "csattimerTraces.h"
       
    27 #endif
       
    28 
       
    29 #include "CSatTimer.h"              // Class header
    23 #include "CSatTimer.h"              // Class header
       
    24 #include "TfLogger.h"               // For TFLOGSTRING
    30 #include "CSatNotificationsTsy.h"   // Sat Tsy class
    25 #include "CSatNotificationsTsy.h"   // Sat Tsy class
    31 #include "CSatDataPackage.h"	        // For data packages
    26 #include "CSatDataPackage.h"	        // For data packages
    32 
    27 
    33 
    28 
    34 // -----------------------------------------------------------------------------
    29 // -----------------------------------------------------------------------------
    54         ( 
    49         ( 
    55         CSatNotificationsTsy* aSatNotificationsTsy
    50         CSatNotificationsTsy* aSatNotificationsTsy
    56         )
    51         )
    57     {
    52     {
    58 
    53 
    59     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATTIMER_CONSTRUCTL_1,  "CSAT: CSatTimer::ConstructL" );
    54     TFLOGSTRING( "CSAT: CSatTimer::ConstructL" );
    60     iSatNotificationsTsy = aSatNotificationsTsy;
    55     iSatNotificationsTsy = aSatNotificationsTsy;
    61     iTimerTable = new ( ELeave ) RArray<TTimer>( KMaxNumberOfParallelTimers );  
    56     iTimerTable = new ( ELeave ) RArray<TTimer>( KMaxNumberOfParallelTimers );  
    62     // Neutral priority, 0
    57     // Neutral priority, 0
    63     iTimer = CHeartbeat::NewL( CActive::EPriorityStandard );
    58     iTimer = CHeartbeat::NewL( CActive::EPriorityStandard );
    64 
    59 
    83 CSatTimer::~CSatTimer
    78 CSatTimer::~CSatTimer
    84         (
    79         (
    85         //None
    80         //None
    86         )
    81         )
    87     {
    82     {
    88     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATTIMER_DTOR_1,  "CSAT: CSatTimer::~CSatTimer" );
    83     TFLOGSTRING( "CSAT: CSatTimer::~CSatTimer" );
    89     if ( iTimer )
    84     if ( iTimer )
    90         {
    85         {
    91         // Stop calling Beat...
    86         // Stop calling Beat...
    92         iTimer->Cancel();
    87         iTimer->Cancel();
    93         delete iTimer;
    88         delete iTimer;
   109         (
   104         (
   110         TInt aTimerId,      // Timer Id
   105         TInt aTimerId,      // Timer Id
   111         TUint32 aTimerValue // Timer value
   106         TUint32 aTimerValue // Timer value
   112         )
   107         )
   113     {
   108     {
   114     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATTIMER_START_1,  "CSAT: CSatTimer::Start" );
   109     TFLOGSTRING( "CSAT: CSatTimer::Start" );
   115     TInt ret( KErrNone );
   110     TInt ret( KErrNone );
   116 
   111 
   117      // Check if the entry is already in the table 
   112      // Check if the entry is already in the table 
   118     if ( CheckTimerTable( aTimerId ) )
   113     if ( CheckTimerTable( aTimerId ) )
   119         {
   114         {
   149 void CSatTimer::Stop
   144 void CSatTimer::Stop
   150         (
   145         (
   151         //None
   146         //None
   152         )
   147         )
   153     {
   148     {
   154     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATTIMER_STOP_1,  "CSAT: CSatTimer::Stop" );
   149     TFLOGSTRING( "CSAT: CSatTimer::Stop" );
   155     // Check if active 
   150     // Check if active 
   156     if ( iTimer->IsActive () ) 
   151     if ( iTimer->IsActive () ) 
   157         { 
   152         { 
   158         // Cancel beat method calling 
   153         // Cancel beat method calling 
   159         iTimer->Cancel(); 
   154         iTimer->Cancel(); 
   191 					);
   186 					);
   192 					
   187 					
   193                 if ( trapError )
   188                 if ( trapError )
   194 					{
   189 					{
   195 					ret = trapError;
   190 					ret = trapError;
   196 					OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATTIMER_BEAT_1, "CSAT: CSatTimer::Beat, Trap error: %d", trapError);
   191 					TFLOGSTRING2("CSAT: CSatTimer::Beat, Trap error: %d", 
       
   192 						trapError);
   197 					}
   193 					}
   198 					
   194 					
   199                 // Remove timer from the table
   195                 // Remove timer from the table
   200                 if ( KErrNone == ret )
   196                 if ( KErrNone == ret )
   201                     {
   197                     {
   219 void CSatTimer::Synchronize
   215 void CSatTimer::Synchronize
   220         (
   216         (
   221         // None
   217         // None
   222         )
   218         )
   223     {
   219     {
   224     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATTIMER_SYNCHRONIZE_1,  "CSAT: CSatTimer::Synchronize" );
   220     TFLOGSTRING( "CSAT: CSatTimer::Synchronize" );
   225     iBeatCounter++;
   221     iBeatCounter++;
   226     }
   222     }
   227 
   223 
   228 // -----------------------------------------------------------------------------
   224 // -----------------------------------------------------------------------------
   229 // CSatTimer::CheckTimerTable
   225 // CSatTimer::CheckTimerTable
   234         (
   230         (
   235         TInt aTimerId
   231         TInt aTimerId
   236         )
   232         )
   237     {
   233     {
   238     
   234     
   239     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATTIMER_CHECKTIMERTABLE_1,  "CSAT: CSatTimer::CheckTimerTable" );
   235     TFLOGSTRING( "CSAT: CSatTimer::CheckTimerTable" );
   240     TBool ret( EFalse );
   236     TBool ret( EFalse );
   241 
   237 
   242     // Create the entry with meaningful values only
   238     // Create the entry with meaningful values only
   243     TTimer timer( aTimerId, 0, 0 );
   239     TTimer timer( aTimerId, 0, 0 );
   244 
   240 
   264         (
   260         (
   265         TInt aTimerId // Timer identifier
   261         TInt aTimerId // Timer identifier
   266         )
   262         )
   267     { 
   263     { 
   268     
   264     
   269     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATTIMER_DELETETIMERBYID_1,  "CSAT: CSatTimer::DeleteTimerById" );
   265     TFLOGSTRING( "CSAT: CSatTimer::DeleteTimerById" );
   270     TInt ret( KErrNotFound );
   266     TInt ret( KErrNotFound );
   271 
   267 
   272     // Create the entry with meaningful values only
   268     // Create the entry with meaningful values only
   273     TTimer timer( aTimerId, 0, 0 );
   269     TTimer timer( aTimerId, 0, 0 );
   274 
   270 
   302 TUint32 CSatTimer::CurrentValueOfTimerById
   298 TUint32 CSatTimer::CurrentValueOfTimerById
   303         (
   299         (
   304         TInt aTimerId // Timer identifier
   300         TInt aTimerId // Timer identifier
   305         )
   301         )
   306     { 
   302     { 
   307     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATTIMER_CURRENTVALUEOFTIMERBYID_1,  "CSAT: CSatTimer::CurrentValueOfTimerById" );
   303     TFLOGSTRING( "CSAT: CSatTimer::CurrentValueOfTimerById" );
   308     TInt ret( KErrNotFound );
   304     TInt ret( KErrNotFound );
   309 
   305 
   310     // Create the entry with meaningful values only
   306     // Create the entry with meaningful values only
   311     TTimer timer( aTimerId, 0, 0 );
   307     TTimer timer( aTimerId, 0, 0 );
   312 
   308 
   346 void CSatTimer::SetProactiveCommandOnGoingStatus
   342 void CSatTimer::SetProactiveCommandOnGoingStatus
   347         ( 
   343         ( 
   348         TBool aStatus 
   344         TBool aStatus 
   349         )
   345         )
   350     {
   346     {
   351     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATTIMER_SETPROACTIVECOMMANDONGOINGSTATUS_1,  "CSAT: CSatTimer::SetProactiveCommandOnGoingStatus" );
   347     TFLOGSTRING( "CSAT: CSatTimer::SetProactiveCommandOnGoingStatus" );
   352     iIsProactiveCommandOnGoing = aStatus;
   348     iIsProactiveCommandOnGoing = aStatus;
   353     }
   349     }
   354 
   350 
   355 // -----------------------------------------------------------------------------
   351 // -----------------------------------------------------------------------------
   356 // CSatTimer::TTimer
   352 // CSatTimer::TTimer
   363         TUint32 aStartTime,  // Timer start time
   359         TUint32 aStartTime,  // Timer start time
   364         TUint32 aTimeStamp   // Time stamp
   360         TUint32 aTimeStamp   // Time stamp
   365         ): iTimerId( aTimerId ), iStartTime( aStartTime ), 
   361         ): iTimerId( aTimerId ), iStartTime( aStartTime ), 
   366            iTimeStamp( aTimeStamp )
   362            iTimeStamp( aTimeStamp )
   367     {
   363     {
   368     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATTIMER_TTIMER_TTIMER_1,  "CSAT: TTimer::TTimer" );
   364     TFLOGSTRING( "CSAT: TTimer::TTimer" );
   369     }
   365     }
   370 
   366 
   371 // -----------------------------------------------------------------------------
   367 // -----------------------------------------------------------------------------
   372 // CSatTimer::TimeStamp
   368 // CSatTimer::TimeStamp
   373 // Gets the value of iTimeStamp
   369 // Gets the value of iTimeStamp
   376 TUint32 CSatTimer::TTimer::TimeStamp
   372 TUint32 CSatTimer::TTimer::TimeStamp
   377         (
   373         (
   378         // None
   374         // None
   379         )
   375         )
   380     {
   376     {
   381     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATTIMER_TTIMER_TIMESTAMP_1,  "CSAT: TTimer::TimeStamp" );
   377     TFLOGSTRING( "CSAT: TTimer::TimeStamp" );
   382     return iTimeStamp;
   378     return iTimeStamp;
   383     }
   379     }
   384 
   380 
   385 // -----------------------------------------------------------------------------
   381 // -----------------------------------------------------------------------------
   386 // CSatTimer::TimerId
   382 // CSatTimer::TimerId
   390 TInt CSatTimer::TTimer::TimerId
   386 TInt CSatTimer::TTimer::TimerId
   391         (
   387         (
   392         // None
   388         // None
   393         )
   389         )
   394     {
   390     {
   395     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATTIMER_TTIMER_TIMERID_1,  "CSAT: TTimer::TimerId" );
   391     TFLOGSTRING( "CSAT: TTimer::TimerId" );
   396     return iTimerId;
   392     return iTimerId;
   397     }
   393     }
   398 
   394 
   399 // -----------------------------------------------------------------------------
   395 // -----------------------------------------------------------------------------
   400 // CSatTimer::TimerStartTime
   396 // CSatTimer::TimerStartTime
   404 TUint32 CSatTimer::TTimer::TimerStartTime
   400 TUint32 CSatTimer::TTimer::TimerStartTime
   405         (
   401         (
   406         // None
   402         // None
   407         )
   403         )
   408     {
   404     {
   409     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATTIMER_TTIMER_TIMERSTARTTIME_1,  "CSAT: TTimer::TimerStartTime" );
   405     TFLOGSTRING( "CSAT: TTimer::TimerStartTime" );
   410     return iStartTime;
   406     return iStartTime;
   411     }
   407     }
   412 
   408 
   413 // -----------------------------------------------------------------------------
   409 // -----------------------------------------------------------------------------
   414 // CSatTimer::CompareEntries
   410 // CSatTimer::CompareEntries
   419         (
   415         (
   420         const CSatTimer::TTimer& aArg1, 
   416         const CSatTimer::TTimer& aArg1, 
   421         const CSatTimer::TTimer& aArg2 
   417         const CSatTimer::TTimer& aArg2 
   422         )
   418         )
   423     {
   419     {
   424     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATTIMER_TTIMER_COMPAREENTRIES_1,  "CSAT: CSatTimer::TTimer::CompareEntries" );
   420     TFLOGSTRING( "CSAT: CSatTimer::TTimer::CompareEntries" );
   425     TBool ret( EFalse ); 
   421     TBool ret( EFalse ); 
   426 
   422 
   427     // We are interested only in the timer id
   423     // We are interested only in the timer id
   428     if ( aArg1.iTimerId == aArg2.iTimerId )
   424     if ( aArg1.iTimerId == aArg2.iTimerId )
   429         {
   425         {
   430         ret =  ETrue;
   426         ret =  ETrue;
   431         }
   427         }
   432     else
   428     else
   433         {
   429         {
   434         OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATTIMER_TTIMER_COMPAREENTRIES_2,  "CSAT: CSatTimer::TTimer::CompareEntries, Not equal" );
   430         TFLOGSTRING( "CSAT: CSatTimer::TTimer::CompareEntries, Not equal" );
   435         }
   431         }
   436     return ret;
   432     return ret;
   437     }
   433     }
   438 
   434 
   439 // -----------------------------------------------------------------------------
   435 // -----------------------------------------------------------------------------
   445         (
   441         (
   446         const CSatTimer::TTimer& aArg1, 
   442         const CSatTimer::TTimer& aArg1, 
   447         const CSatTimer::TTimer& aArg2  
   443         const CSatTimer::TTimer& aArg2  
   448         ) 
   444         ) 
   449     {
   445     {
   450     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATTIMER_TTIMER_ORDERENTRIES_1,  "CSAT: CSatTimer::TTimer::OrderEntries" );
   446     TFLOGSTRING( "CSAT: CSatTimer::TTimer::OrderEntries" );
   451     TInt ret( KFirstTimeStampSmaller );
   447     TInt ret( KFirstTimeStampSmaller );
   452 
   448 
   453     // We are interested only in the time stamp
   449     // We are interested only in the time stamp
   454     if ( aArg1.iTimeStamp == aArg2.iTimeStamp )
   450     if ( aArg1.iTimeStamp == aArg2.iTimeStamp )
   455         {
   451         {
   459         {
   455         {
   460         ret = KFirstTimeStampBigger;
   456         ret = KFirstTimeStampBigger;
   461         }
   457         }
   462     else
   458     else
   463         {
   459         {
   464         OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATTIMER_TTIMER_ORDERENTRIES_2,  "CSAT: CSatTimer::TTimer::OrderEntries, KFirstTimeStampSmaller" );
   460         TFLOGSTRING( "CSAT: CSatTimer::TTimer::OrderEntries, \
       
   461             KFirstTimeStampSmaller" );
   465         }
   462         }
   466 
   463 
   467     return ret;
   464     return ret;
   468     }
   465     }
   469 
   466